Updated on 2022-07-13 GMT+08:00

Connecting a Native Docker Application to APM

If you have a Java application image, you can add the parameters required by the Java probe to the native Docker startup command. In this case, by starting the image, you can connect the Java application to APM, and then view application data on the topology and transaction pages.

Prerequisite

You have deployed a Java application in Docker.

Procedure

Step 1: Subscribe to APM

See Subscribing to APM and Buying a Package.

Step 2: Install the ICAgent

  1. Obtain an Access Key ID/Secret Access Key (AK/SK).
  2. Log in to the APM console.
  3. In the navigation pane, choose Agent > Management.
  4. Click Install ICAgent. On the page that is displayed, set Host to HUAWEI CLOUD host and OS to Linux.
  5. Select the Obtain AK/SK installation mode, enter the obtained AK/SK in the text box to generate the ICAgent installation command, and click Copy Command.

    Ensure that the AK/SK are correct. Otherwise, the ICAgent cannot be installed.

  6. Remotely log in to the Elastic Cloud Server (ECS) server as the root user and run the preceding command to install the ICAgent.

    When the message "ICAgent install success" is displayed, the ICAgent is successfully installed in the /opt/oss/servicemgr/ directory.

(Optional) Step 3: Modify Permissions

If you start the program as a non-root user, run the following commands to modify the permissions on the probe file and output directory before enabling application monitoring:

chmod -R 777 /opt/oss/servicemgr/ICAgent/pinpoint/
mkdir -p /opt/apm-container 
chmod -R 777 /opt/apm-container 

Step 4: Start an Image

Add the parameters required by the Java probe to the native Docker startup command, and adjust the application and service names as required. The following shows an example of the VMall application with the vmall-dao-service service.

  1. Modify the Docker startup script.

    Example

    Original startup command:
    docker run -p 8080:8080 demo:latest
    Modified startup command:
    docker run -e JAVA_TOOL_OPTIONS="-javaagent:/opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar -Dapm_application=vmall -Dapm_tier=vmall-dao-service -Dapm_container=true" -v /opt/apm-container:/paas-apm/collectors/pinpoint -v /opt/oss/servicemgr/ICAgent/pinpoint:/opt/oss/servicemgr/ICAgent/pinpoint -p 8080:8080 demo:latest
  2. Run the docker run command to start the image, so that the Docker application can be connected to the APM console.

Step 5: Manage the Application on APM

Three minutes after the application is started, its data will be displayed on the APM console. You can log in to the APM console and optimize application performance through topology and tracing. For details, see APM User Guide.