Updated on 2024-03-06 GMT+08:00

Manually Installing Agents for Java Applications

Prerequisites

  • The network between your host and APM is normal.

    You can run the Telnet command to check the network.

    For example, to check the network connectivity in the CN-Hong Kong region, log in to the host where the application is deployed and run the telnet 100.125.6.106:41333 command. For details about the access addresses of other regions, see Access Addresses.

  • The AK/SK required for accessing JavaAgents have been obtained. To obtain them, log in to the APM console and choose System Management > Access Keys in the navigation pane.
    Figure 1 Obtaining an AK/SK

Procedure

  1. Download apm-javaagent-x.x.x.zip to any directory of your host. For the download address, see JavaAgent Download Addresses.

    Example command:

    curl -O https://xxx/apm-javaagent-x.x.x.tar

  1. Run the tar command to decompress the JavaAgent package.

    Example command:

    tar -xvf apm-javaagent-x.x.x.tar

  1. Modify the apm.config file in the JavaAgent package. Configure master.address by referring to Access Address (master.address), and add the AK/SK to the configuration file, as shown in the following figure.

    Figure 2 Adding the AK/SK

  1. Modify the startup script of the Java process.

    Add the path of the apm-javaagent.jar package and the component name of the Java process to the end of the Java command in the service startup script.

    Example of adding -javaagent parameters:

    java -javaagent:/xxx/apm-javaagent/apm-javaagent.jar=appName={appName}

    If your enterprise has a large number of services, you can add more complex configurations. For example:

    java -javaagent:/xxx/apm-javaagent/apm-javaagent.jar=appName=myApp,env=myEnv,envTag=myTag,business=myBusiness,subBusiness=mySub
    • The preceding parameters are built-in CMDB information of APM. For details, see CMDB Management.
    • Due to historical reasons, the metadata of APM startup parameters conflicts with some CMDB concepts. The following shows the details.

      Generally, the startup parameter is set to -javaagent:D:\javaagent-package\apm-javaagent\apm-javaagent.jar=appName=xxx,env=yyy,business=zzz,subBusiness=sss,envTag=xxx. appName indicates a component, business indicates an application, subBusiness indicates a sub-application, and envTag indicates an environment tag.

      If business is not set on the web page, the system reports an error when the JavaAgent is started. If other parameters (subBusiness, appName, env, and envTag) are not set, the system automatically creates them when the JavaAgent is started.

      Component names are unique under an application.

  2. Redeploy the application.