Manually install the agent

更新时间:
复制 MD 格式

After you install the agent for a Java application, Cloud Monitor 2.0 starts monitoring the application. You can view various monitoring data, such as application topology, call stacks, abnormal transactions, slow transactions, and SQL analysis. This topic describes how to manually install the agent for a Java application.

Note

For applications that are deployed in a Kubernetes environment, manual agent installation is not recommended. Instead, install the agent by installing a component. For more information, see Install the Java agent for Container Service for Kubernetes (ACK) and Container Compute Service (ACS) using the ack-onepilot component.

Prerequisites

Install the agent

  1. Log on to the Cloud Monitor 2.0 console, and select a workspace. In the left navigation pane, click Integration Center.

  2. Click the Java Application Monitor card. In the panel that appears, click Manual Installation.

  3. Download an ARMS agent.

    • Method 1: Manually download an ARMS agent. In the Java Application Monitor panel, download an ARMS agent as prompted.

    • Method 2: Run the wget command. Download the installation package based on your region.

      wget commands in different regions

      Region

      Public URL

      VPC

      China (Hangzhou)

      wget "http://arms-apm-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-hangzhou.oss-cn-hangzhou-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China (Shanghai)

      wget "http://arms-apm-cn-shanghai.oss-cn-shanghai.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-shanghai.oss-cn-shanghai-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China (Qingdao)

      wget "http://arms-apm-cn-qingdao.oss-cn-qingdao.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-qingdao.oss-cn-qingdao-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China (Beijing)

      wget "http://arms-apm-cn-beijing.oss-cn-beijing.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-beijing.oss-cn-beijing-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China (Zhangjiakou)

      wget "http://arms-apm-cn-zhangjiakou.oss-cn-zhangjiakou.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-zhangjiakou.oss-cn-zhangjiakou-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China (Hohhot)

      wget "http://arms-apm-cn-huhehaote.oss-cn-huhehaote.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-huhehaote.oss-cn-huhehaote-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China (Ulanqab)

      wget "http://arms-apm-cn-wulanchabu.oss-cn-wulanchabu.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-wulanchabu.oss-cn-wulanchabu-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China (Shenzhen)

      wget "http://arms-apm-cn-shenzhen.oss-cn-shenzhen.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-shenzhen.oss-cn-shenzhen-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China (Heyuan)

      wget "http://arms-apm-cn-heyuan.oss-cn-heyuan.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-heyuan.oss-cn-heyuan-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China (Guangzhou)

      wget "http://arms-apm-cn-guangzhou.oss-cn-guangzhou.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-guangzhou.oss-cn-guangzhou-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China (Chengdu)

      wget "http://arms-apm-cn-chengdu.oss-cn-chengdu.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-chengdu.oss-cn-chengdu-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China (Hong Kong)

      wget "http://arms-apm-cn-hongkong.oss-cn-hongkong.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-hongkong.oss-cn-hongkong-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      Singapore

      wget "http://arms-apm-ap-southeast-1.oss-ap-southeast-1.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-ap-southeast-1.oss-ap-southeast-1-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      Malaysia (Kuala Lumpur)

      wget "http://arms-apm-ap-southeast-3.oss-ap-southeast-3.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-ap-southeast-3.oss-ap-southeast-3-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      Indonesia (Jakarta)

      wget "http://arms-apm-ap-southeast-5.oss-ap-southeast-5.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-ap-southeast-5.oss-ap-southeast-5-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      Japan (Tokyo)

      wget "http://arms-apm-ap-northeast-1.oss-ap-northeast-1.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-ap-northeast-1.oss-ap-northeast-1-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      Germany (Frankfurt)

      wget "http://arms-apm-eu-central-1.oss-eu-central-1.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-eu-central-1.oss-eu-central-1-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      UK (London)

      wget "http://arms-apm-eu-west-1.oss-eu-west-1.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-eu-west-1.oss-eu-west-1-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      US (Virginia)

      wget "http://arms-apm-us-east-1.oss-us-east-1.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-us-east-1.oss-us-east-1-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      US (Silicon Valley)

      wget "http://arms-apm-us-west-1.oss-us-west-1.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-us-west-1.oss-us-west-1-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China East 1 Finance

      wget "http://arms-apm-cn-hangzhou-finance.oss-cn-hzjbp-b-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China East 2 Finance

      wget "http://arms-apm-cn-shanghai-finance-1.oss-cn-shanghai-finance-1-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China South 1 Finance

      wget "http://arms-apm-cn-shenzhen-finance-1.oss-cn-shenzhen-finance-1-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip

      China North 2 Ali Gov

      wget "http://arms-apm-cn-north-2-gov-1.oss-cn-north-2-gov-1.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
      wget "http://arms-apm-cn-north-2-gov-1.oss-cn-north-2-gov-1-internal.aliyuncs.com/AliyunJavaAgent.zip" -O AliyunJavaAgent.zip
  4. Decompress the installation package.

    Go to the directory of the installation package. Run the following command to decompress the installation package to a working directory:

    unzip AliyunJavaAgent.zip -d /{user.workspace}/ 
    Note

    {user.workspace} is a sample directory. Replace the sample directory with the actual directory.

  5. Add the AppName and LicenseKey parameters.

    On the Java Application Monitoring panel, obtain the LicenseKey. The AppName parameter specifies the application in ARMS that you want to connect to. You can customize the application name as required. In a distributed architecture, an application can contain multiple peer instances.

    Important

    The LicenseKey is specific to each workspace. You must obtain a new LicenseKey for a new workspace.

    You can add the AppName and LicenseKey in one of the following ways.

    • Method 1 (Recommended): In the startup script, replace {LicenseKey} and {AppName} with the LicenseKey that you obtained from the console and the AppName of your application.

    • Method 2: If you want to reuse the startup script for different applications, you can specify the LicenseKey and AppName by modifying the agent configuration file. To do this, perform the following steps:

      Note

      For agent versions earlier than 4.4.0, this method connects the application to the default workspace.

      1. In the version file that you unzipped in the previous step, check the Java agent version.

      2. Modify the agent configuration file.

        Agents of version 4.0.0 and later

        In the agent directory, create a file named arms-agent.properties and add the following configurations. Then, add -Dotel.javaagent.configuration-file=/path/to/arms-agent.properties to the startup command or add the OTEL_JAVAAGENT_CONFIGURATION_FILE=/path/to/arms-agent.properties environment variable to enable the configuration file.

        arms.licenseKey={LicenseKey} 
        arms.appName={AppName}

        Agents earlier than version 4.0.0

        In the arms-agent.config file within the agent package, add the following configurations.

        arms.licenseKey={LicenseKey} 
        arms.appName={AppName}
        Note

        For more information about other configuration items in the agent configuration file, see Modify the Java agent configuration file and the default reporting region.

  6. Add the connection command to the startup command.

    Replace {user.workspace} with the directory where you unzipped the agent installation package. Replace demoApp.jar with the actual path of your JAR package.

    Note
    • If you are using an agent version earlier than 2.7.3.5, replace AliyunJavaAgent/aliyun-java-agent.jar in this topic with ArmsAgent/arms-bootstrap-1.7.0-SNAPSHOT.jar. We recommend that you upgrade the agent to the latest version as soon as possible.

    • On a Windows operating system, replace / with \ and replace the .sh file extension with .bat in the script.

    • Agents of V2.7.1.4 and later support application security. To enable application security when you connect to Application Monitoring, add -Darms.appsec.enable=true to the script. For more information about the billing rules for application security, see Billing.

    Runtime environment

    Steps

    Spring Boot or other Java applications that are started using the java -jar command

    Add the -javaagent parameter to the startup command. Make sure that the -javaagent parameter is placed before the -jar parameter.

    java -javaagent:/{user.workspace}/AliyunJavaAgent/aliyun-java-agent.jar -Darms.licenseKey={LicenseKey} -Darms.appName={AppName} -Darms.workspace={workspace} -jar demoApp.jar

    Tomcat

    Add the following configuration to the {TOMCAT_HOME}/bin/setenv.sh file.

    JAVA_OPTS="$JAVA_OPTS -javaagent:/{user.workspace}/AliyunJavaAgent/aliyun-java-agent.jar -Darms.licenseKey={LicenseKey} -Darms.appName={AppName} -Darms.workspace={workspace} " 

    If your Tomcat version does not have the setenv.sh configuration file, open the {TOMCAT_HOME}/bin/catalina.sh file and add the preceding configuration after JAVA_OPTS. For an example, see line 256 of catalina.sh.

    Jetty

    Add the following configuration to the {JETTY_HOME}/start.ini configuration file.

    aliyun-java-agent.jar --exec
    -javaagent:/{user.workspace}/AliyunJavaAgent/aliyun-java-agent.jar
    -Darms.licenseKey={LicenseKey}
    -Darms.appName={AppName} 
    -Darms.workspace={workspace} 

    To deploy multiple instances of the same application on a single server, you can use the -Darms.agentId parameter (a logical ID) to differentiate the connected Java Virtual Machine (JVM) processes. For example:

    java -javaagent:/{user.workspace}/AliyunJavaAgent/aliyun-java-agent.jar -Darms.licenseKey={LicenseKey} -Darms.appName={AppName} -Darms.workspace={workspace} -Darms.agentId=001 -jar demoApp.jar
  7. Restart the Java application.

View monitoring details

  1. Log on to the Cloud Monitor 2.0 console, and select a workspace. In the left navigation pane, choose Application Center > Application Observability > Application Insights.

  2. On the Application List page, you can see the connected applications. Click an application name to view its detailed monitoring data.