Application Real-Time Monitoring Service (ARMS) provides application monitoring features such as application trace analysis, local stack diagnosis, and business log troubleshooting. To monitor an application by using ARMS, you must create an application monitoring job.

Background information

ARMS can monitor Java and PHP applications that run in various environments. This topic describes how to create an application monitoring job for a Java application that runs on an Elastic Compute Service (ECS) instance in the Tomcat environment. To ensure that you can monitor applications in different environments, ARMS allows you to install the ARMS agent manually or using scripts. However, to help you understand the general steps for creating an application monitoring job, this topic describes how to manually install the ARMS agent.

Prerequisites

  • Activate and upgrade ARMS
  • Ports 8442, 8443, and 8883 in the security group have been opened for TCP outbound access. For more information about how to grant outbound permissions to ECS, see Add security group rules.
    Note In addition to applications on Alibaba Cloud ECS instances, applications on public network servers can also access ARMS.

Step 1: Obtain the license key

Perform the following steps to obtain the license key:

  1. Log on to the ARMS console.
  2. In the left-side navigation pane, choose Application Monitoring > Applications.
  3. On the Applications page, select a region in the top navigation bar, and click Add Application in the upper-right corner.
  4. Copy the license key at the top of the Add Application page.
    Download Agent

Step 2: Configure the Tomcat runtime environment

Perform the following steps to configure the Tomcat runtime environment and set the required parameters in the configuration file:

  1. Open the {TOMCAT_HOME}/bin/catalina.sh configuration file.
    Note If your Tomcat does not contain the catalina.sh configuration file, find and open the {TOMCAT_HOME}/bin/setenv.sh configuration file.
  2. Append the following configurations to the configuration file:
    Note Replace <licenseKey> in the following sample code with the license key that you obtained in Step 1. Replace <appName> with the name of your application.
    JAVA_OPTS="$JAVA_OPTS -javaagent:/workspace/ArmsAgent/arms-bootstrap-1.7.0-SNAPSHOT.jar -Darms.licenseKey=<licenseKey> -Darms.appName=<appName>"
                        

The following sample code shows how to configure the Tomcat runtime environment:

Step 3: Install the ARMS agent for Java applications

Perform the following steps to install the ARMS agent for Java applications and collect the monitoring data that you need:

  1. Run the wget command to download the compressed package of the ARMS agent for Java applications.
    Note The China (Hangzhou) region is used in this example. For the download links of the ARMS agent for Java applications in other regions, see Procedure.
    # China (Hangzhou)
    wget "http://arms-apm-hangzhou.oss-cn-hangzhou.aliyuncs.com/ArmsAgent.zip" -O ArmsAgent.zip
  2. Decompress the package of the ARMS agent for Java applications to a working directory. In this example, the working directory is workspace.
    unzip ArmsAgent.zip -d /workspace/

The following sample code shows how to install the ARMS agent for Java applications:

Step 4: Restart Tomcat

  1. Go to the {TOMCAT_HOME}/bin directory.
  2. Restart Tomcat.
    ./startup.sh

The following sample code shows how to restart Tomcat:

Verify the result

After 2 to 3 minutes, log on to the ARMS console. In the left-side navigation pane, choose Application Monitoring > Applications. If your application (specified by the <appName> parameter) appears on the Applications page, it indicates that the application monitoring job is created.