APM agent for Java docker application

Hi Team,

I am trying to configure Elastic APM for dockerized Java application..

Kindly let me know the steps to configure Java APM agent for docker Java apps..


Hi and welcome to the forum :slight_smile:

You would have to copy the agent jar to the container's filesystem and then edit the command line that starts your Java app to contain the -javaagent flag with the proper jar location within the container.
You can get general info about the Java agent setup options in our documentation. You can configure the agent through system or environment properties, or through a configuration file (which you will have to make available in the container filesystem as well).

I hope this helps.

The attach API is an alternative which does not require to copy the agent jar into the container. However, it is an additional dependency to your application.

Hi Team,

My application is java based and deploying it as EAR file not JAR.

And there is no placeholder for Programmatic API setup.

I have added below lines in the Dockerfile and tried.

ADD elastic-apm-agent-1.6.0.jar $BWCE_HOME

ENV JAVA_OPTS=-javaagent:$BWCE_HOME/elastic-apm-agent-1.6.0.jar -Delastic.apm.service_name=hello -Delastic.apm.application_packages=org.example -Delastic.apm.server_url=

Still no luck.

Is there any other method?


Sorry, I don't know anything about working with BWCE.
If the JAVA_OPTS variable contents are appended to the command line that runs the Java container that runs your EAR file, then this looks right (except from the elastic.apm.application_packages, which you should either omit or change to contain your application base java package). Otherwise, you would need to figure out what is the right way to configure the Java that runs this EAR.
You should of course also make sure that the APM server URL you used is reachable from the container.
Try looking in the application logs to get some feedback.
Sorry I can't provide a lot of info, your knowledge in this env is surely much greater than mine.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.