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.
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
The network configurations meet the requirements. For more information, see Network configurations required by the ARMS agent for Java.
The version of the JDK is supported by Application Monitoring. For more information, see Java components and frameworks supported by ARMS.
The maximum heap memory of the process is greater than 256 MB.
Install the agent
Log on to the Cloud Monitor 2.0 console, and select a workspace. In the left navigation pane, click Integration Center.
Click the Java Application Monitor card. In the panel that appears, click Manual Installation.
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.
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.
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.
ImportantThe 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:
NoteFor agent versions earlier than 4.4.0, this method connects the application to the default workspace.
In the version file that you unzipped in the previous step, check the Java agent version.
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.propertiesto the startup command or add theOTEL_JAVAAGENT_CONFIGURATION_FILE=/path/to/arms-agent.propertiesenvironment 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}NoteFor more information about other configuration items in the agent configuration file, see Modify the Java agent configuration file and the default reporting region.
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.NoteIf 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.shfile extension with.batin 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=trueto 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 -jarcommandAdd 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.jarTomcat
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.jarRestart the Java application.
View monitoring details
Log on to the Cloud Monitor 2.0 console, and select a workspace. In the left navigation pane, choose .
On the Application List page, you can see the connected applications. Click an application name to view its detailed monitoring data.