Before you Begin
This tutorial shows you how to install an APM Java Agent on a Tomcat Application Server.
Background
APM Java Agents can record application server spans and metrics and send them to Application Performance Monitoring Cloud Service for analysis.
Perform Prerequisites
- Check the supported application servers and versions. In this example, the application server is Apache Tomcat/7.0.68 JDK8, on a Linux system.
- Make a note of your application server installation home.
- Perform Oracle Cloud Infrastructure Prerequisites, if you don't aready have an OCI environment set up:
Note:
You need total disk space of approx 175MB for the Agent.Step 1: Create an APM domain
-
Sign in to the Oracle Cloud Infrastructure console, open the navigation menu, and click Observability and Management. Under Application Performance Monitoring, click Administration and then Create Domain:
View your newly created domain and make a note of the Data Upload Endpoint:
When you create an APM Domain, a pair of private/public keys is generated automatically. Make a copy of the private key that was generated for your domain by clicking Copy.
Step 2: Download the Agent Files
Navigate to Download APM Agent and click Java Agent and save the agent jar file:
Check the checksum of the downloaded file to confirm your copy is identical to the one available on the APM Download page:
sha256sum apm-java-agent-installer-1.1.jar
-
Copy the agent jar file to your app sever host, if needed.
Step 3: Provision the APM Java Agent
The Java Agent destination can be any directory you choose. As best practice, in this example it is provisioned in the CATALINA_HOME
, the location of the Apache Tomcat. First, navigate to the directory when your agent .jar
file is. Then enter the following commands to provision the agent:
setenv JAVA_HOME /opt/jdk8
setenv CATALINA_HOME /u01/tomcat/orderApp-tomcat4
java -jar ./apm-java-agent-installer-1.1.jar provision-agent -service-name=my_service -destination=$CATALINA_HOME -private-data-key=AAA5UN2C6YOWWWUZ5Q7UUU3QACF4BBB -data-upload-endpoint=https://aaaaaaaaaaaaaaaaaaaa-ashburn-1.oci.oraclecloud.com
Sample output:
Action [provision-agent] completed successfully
********************************************
APM Agent has been provisioned successfully. To complete the setup, you need to
modify your destination's appserver startup script so that the APM Agent you
have just deployed can be started. Here is the general information on the changes [...]
Step 4: Deploy the APM Java Agent
Make a backup copy of the
catalina.sh
file.cd CATALINA_HOME/bin
cp catalina.sh catalina.sh.orig
Use a text editor and edit the original
catalina.sh
file and add the following-javaagent
option toCATALINA_OPTS
. Make the change outside of anyif
statements or code blocks that may not be executed during server startup. This will ensure that the-javaagent
flag is always added to the server startup options.CATALINA_OPTS="${CATALINA_OPTS} -javaagent:$CATALINA_HOME/oracle-apm-agent/bootstrap/ApmAgent.jar"
Stop and restart the Apache Tomcat Server:
cd $CATALINA_HOME/bin
./shutdown.sh
Sample output:
Using CATALINA_BASE: /u01/tomcat/orderApp-tomcat4
Using CATALINA_HOME: /u01/tomcat/orderApp-tomcat4
Using CATALINA_TMPDIR: /u01/tomcat/orderApp-tomcat4/temp
Using JRE_HOME: /opt/jdk8
Using CLASSPATH: /u01/tomcat/orderApp-tomcat4/bin/bootstrap.jar:/u01/tomcat/orderApp-tomcat4/bin/tomcat-juli.jar
Catalina home is /u01/tomcat/orderApp-tomcat4./startup.sh
Sample output:
Using CATALINA_BASE: /u01/tomcat/orderApp-tomcat4
Using CATALINA_HOME: /u01/tomcat/orderApp-tomcat4
Using CATALINA_TMPDIR: /u01/tomcat/orderApp-tomcat4/temp
Using JRE_HOME: /opt/jdk8
Using CLASSPATH: /u01/tomcat/orderApp-tomcat4/temp/bin/bootstrap.jar:/u01/tomcat/orderApp-tomcat4/bin/tomcat-juli.jar
Catalina home is /u01/tomcat/orderApp-tomcat4
Step 5: Verify Your APM Java Agent Deployment
Verify that your agent was successfully deployed by looking at the agent deployment logs as well as the Application Performance Monitoring Cloud Service user interface. The Agent is provisioned in $CATALINA_HOME/oracle-apm-agent
.
-
The logs are located in the agent location you chose above.
cd $CATALINA_HOME/oracle-apm-agent
The log directory should have the following log files:AgentErrors.log, Agent.log, AgentStartup.log, AgentStatus.log
- Check the
AgentStartup.log
file and look for a success message:cat AgentStartup.log
Agent successfully initialized
- Check the
AgentStatus.log
file and look for short status messages that indicate that the APM Java agent is active. - Navigate to Application Performance Monitoring , click on Trace Explorer and check that trace data from the application server is being uploaded.
Note:
The Agent typically requires about 200MB of JVM memory heap space, so you may need to adjust the JVM's memory heap settings (-Xmx) appropriately.Learn More
Install an APM Java Agent on a Tomcat Application Server
F40498-02
November 2021
Copyright © 2021, Oracle and/or its affiliates.
This tutorial shows you how to install an APM Java Agent on a Tomcat Application Server
This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.
If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable:
U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are "commercial computer software" or "commercial computer software documentation" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, reproduction, duplication, release, display, disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other Oracle data, is subject to the rights and limitations specified in the license contained in the applicable contract. The terms governing the U.S. Government's use of Oracle cloud services are defined by the applicable contract for such services. No other rights are granted to the U.S. Government.
This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc, and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.
This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle.