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.

  • 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

    Figure 1 Obtaining an AK/SK

Procedure

  1. Download apm-javaagent 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

  2. 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

    Figure 2 Adding the AK/SK

  3. 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

    Note

    • 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.

  4. Redeploy the application.