[Webinar] Discover key trends and best practices in Kubernetes observability with DevOps expert, Viktor Farcic.Register now
Our recognition in the inaugural Gartner MQ for DEM

Install APM Insight Java Agent in Docker


Follow the steps given below to install Java agent in Docker:

  1. Download the latest APM Insight Java agent (apminsight-javaagent.zip) file.
  2. Extract the zip file to a new directory to find agent jar and its configuration files.
  3. Open the apminsight.conf file in any text editor and include/modify the following keys:

    license.key=[LICENSE KEY]
    apm.host=http://[HOST]:[PORT]
    application.name=[APPLICATION NAME]

    where
    • [LICENSE KEY] - License key obtained from Applications Manager under APM Insight tab.
    • [HOST] - Host at which Applications Manager is running.
    • [PORT] - Port number at which Applications Manager is running.
    • [APPLICATION NAME] - Name of your application.

    Example:

    license.key=APMI_74447444b666d7ab5174cc3021a9b68dd4b3364d50f99c2969360810313e8fac
    apm.host=http://apm-prod-server:9090
    application.name=Docker_Server

    To learn more about the configurations, visit our Configuration Guide page.

    Note: Alternatively, the APM Insight application configuration parameters can also be configured as Java System Properties instead of modifying the apminsight.conf file. Learn more

  4. Now create/modify the image file named Dockerfilein the directory location of your choice and include the following commands into the image file:

    #Creating a new directory 'apminsight' under the specified app directory location
    RUN mkdir -p <APP_DIRECTORY_PATH>/apminsight
    #Adding the agent directory files into the specified app directory path under 'apminsight'
    ADD <Agent_directory_path>/ <APP_DIRECTORY_PATH>/apminsight/
    #Configuring Java agent into the application
    ENV JAVA_OPTS="$JAVA_OPTS -javaagent:<APP_DIRECTORY_PATH>/apminsight/apminsight-javaagent.jar"

    where
    • <APP_DIRECTORY_PATH> - Directory where the application is installed.
    • <Agent_directory_path> - Directory where the Java agent is extracted.
  5. Save the file, rebuild the image and start the container.
Note:
  • You can also configure a secure APM URL. Ensure that the connection is stable and free from certificate-related issues.
    Example: https://apm-prod-server:8443
  • For an Applications Manager failover setup, you can specify multiple hosts in a comma-separated format (supported from Java Agent v6.8), as shown below:
    apm.host=http://apm-prod-server-A:9090, http://apm-prod-server-B:9090

Example:

Following is an example of the commands used for configuring the agent into the image file Dockerfile for Tomcat servers:

FROM tomcat
COPY sample.war /usr/local/tomcat/webapps/
#Add the apminsight and -javaagent parameters
RUN mkdir -p /usr/local/tomcat/apminsight
ADD ./apminsight/ /usr/local/tomcat/apminsight/
ENV JAVA_OPTS="$JAVA_OPTS -javaagent:/usr/local/tomcat/apminsight/apminsight-javaagent.jar"
EXPOSE 8080
CMD ["catalina.sh","run"]

Note: To add the agent to server, the -javaagent argument needs to provided. However, this method is a generic solution and may require some modifications depending on your app server/user environment.

Back to Top