To begin monitoring a Java application using AppDynamics, you install the AppDynamics Java Agent into the application JVM:

Download the agent distribution to the machine where your Java application runs.

Configure the Java Agent settings. This configuration section of topic describes manual configuration, for more options, see Administer the Java Agent.

Add the agent into the JVM process.

Prepare to Install the Java Agent

Consider the following as you decide where and how to deploy the AppDynamics Java Agent:

The user under which the JVM runs must have write privileges to the conf and logs directories in the Java Agent home. To achieve this, you can install the agent as the same user that owns the JVM or as an administrator on the host machine. You can restrict the remaining contents of the agent directory to read only access.

If the agent connects to the Controller via a local proxy, you must configure proxy settings for the agent. See "Proxy Properties for the Controller" in Java Agent Configuration Properties for more information.

The Java Agent supports sharing a single agent between multiple JVMs running on the same machine. If you choose this deployment scenario, you will likely want to specify settings in a combination of system properties and the versioned configuration file. See Instrument Multiple JVMs on a Single Machine for example configurations.

The AppDynamics Java Agent is one type of bytecode injection (BCI) agent. To prevent unforeseen issues with other BCI agents, AppDynamics only supports environments running the AppDynamics Java Agent as the sole BCI agent on the JVM.

Java Agent Resource Overhead

However, certain factors can increase CPU overhead from the agent beyond 2%. These include the use of resource-intensive AppDynamics features, such as asynchronous transaction tracking. Very active environments or configuration settings that result in a high number of metrics or snapshots reported per minute can also affect agent resource consumption.

In all cases, AppDynamics recommends that you test the agent in a staging environment, and monitor resource consumption of your application to ensure that it remains within proper operating parameters.

If your application operates within a small margin of its existing memory resource allocation, you may choose to increase the allocation for the application. AppDynamics recommends allocating the following amounts of additional Heap and PermGen space to accommodate the agent:

Maximum heap size (-Xmx): 100 MB in addition to the amount required by the application

Download and Unzip the Java Agent Distribution

You can get the agent from the Agent Download Wizard. If you have never installed an agent before, the wizard is a good place to start. The wizard populates the configuration file in the agent you download with Controller connection settings and identifying settings for the agent. After you download the agent, you can install it in the JVM, as described ...

Extract the ZIP file to the destination directory as the same user or administrator of the JVM. Note the following:

Extract the Java Agent to a directory that is outside of your container or application server runtime directories, such as to \usr\local\appdynamics\appagent.

All files should be readable by the user under which the JVM runs. The user must have write privileges to the conf and logs directories in the Java Agent home. One way to achieve this is to install the agent as the same user that owns the JVM or as an administrator on the host machine.

The application server's runtime directory should be writable by the Java Agent as well.

Configure the Java Agent

If you downloaded the agent from the Agent Download Wizard in the Controller, you can jump ahead to the next section, as the agent is already configured.

To configure the settings manually (or verify the wizard settings):

Edit the versioned configuration file: <agent_home>/<version_number>/conf/controller-info.xmlThe controller-info.xml is one of several approaches available for supplying configuration settings. For others, see Java Agent Configuration Properties.

Modify the connection settings to the Controller:

controller-host: Set to the IP address or hostname of the Controller. If the agent needs to connect through a proxy, see "Proxy Properties for the Controller" in Java Agent Configuration Properties.

controller-port: Set to the primary listening port number on the Controller. By default:

For a SaaS Controller, use 80 for HTTP or 443 for HTTPS

For an on-premises Controller, use 8090 for HTTP or 8181 for HTTPS

Direct the agent to connect to the Controller by SSL (HTTPS) by setting the controller-ssl-enabled value to true. See Enable SSL for the Java Agent.

Identify the business application, tier, and node that this the monitored JVM belongs to in the AppDynamics application model using these settings:

application-name

tier-name

node-name

In a self-service Trial edition of AppDynamics Pro, the agent uses a default naming scheme, see Java Agent. You can use automatic naming with a standard edition of AppDynamics Pro by adding the following property:<auto-naming>true</auto-naming>

If the agents connects to a SaaS Controller or other multi-tenant Controller, configure the Account Name. For all Controllers, configure the Account Access Key.

account-name

account-access-key

This information is provided in the Welcome email from the AppDynamics Team when you acquired the Controller. For a multi-tenant on-premises Controller, you can find this information in<controller_home>/initial_account_access_info.txt

Load the Java Agent in a JVM

After configuring the agent settings, you can add the agent to the JVM. The exact steps for doing so vary by framework. The general approach, however, involves specifying the agent as a ‑javaagent argument to the startup command for the JVM.

The argument should indicate the location of the Java Agent JAR file:

-javaagent:<agent_home>/javaagent.jar

On Windows, include the drive letter in the path to the agent:

-javaagent:C:<agent_home>\javaagent.jar

Adding the javaagent to the startup script requires a restart of the JVM. If it's not possible to restart the JVM when you are installing the agent and modifying the JVM start up script, you can attach the agent dynamically to the running Java process, as described next.

Attaching the Java Agent to a Running JVM Process

Attaching the agent to a running JVM allows you to install the Java Agent without requiring a JVM restart. This approach would normally be used alongside adding the ‑javaagent argument to the JVM startup script, or some other persistent approach to ensure that the agent is loaded again at the next JVM restart. However, dynamic attachment allows you to install the agent when restarting the JVM is not possible or convenient.

Dynamic agent attachment works if:

The JVM is version 1.6 or later.

The JVM is an Oracle (HotSpot) JVMs (unavailable for IBM or JRockit JVMs).

Other considerations include:

Do not attach the agent dynamically to an environment that is already instrumented (either by the AppDynamics Java Agent or another type of agent). Doing so can cause unforeseeable issues and errors.

Attaching the AppDynamics Java Agent to a running environment will impact the performance of the application while the agent performs the class retransformation needed to instrument the application. The agent overhead will return to its normal operating level when it finishes the process, but it is important to consider the potential performance impact to production services.

To attach the agent to the JVM, follow these steps:

Determine the PID of the JVM to which you want to attach. For example, on Linux, use:

ps -A | grep java

On Windows, use:

jps -l

Run the following command, replacing the placeholders for the path to the tools.jar file in your JDK, path to the AppDynamics Java Agent home directory, and the JVM process ID with values appropriate for your environment:

Verify Java Agent Installation

After a installation, the agent log in <agent_home>/logs will contain the following message:

Started AppDynamics Java Agent Successfully

If the agent log file is not present, the Java Agent may not be accessing the javaagent command properties. To troubleshoot, check the application server log file where STDOUT is logged. It will have the fallback log messages, useful for troubleshooting the agent.

Also, verify that the agent is able to connect to the Controller in the Controller UI. To verify, log in to the Controller UI and click the Settings cog icon at the top right of the screen, and then AppDynamics Agents. In the list, look for the agent in the list by machine hostname.