spring-bootopenshiftjavaagentsapmelastic-apm

Run a Spring Boot application with elastic-apm Java agent on OpenShift


I want to deploy a Spring Boot application on an OpenShift cluster that I want to monitor with elastic-apm, therefore, with the JAVA elastic agent.

I managed to deploy in a project an Elasticsearch instance, a Kibana instance and an apm-server.

Next to that, I also managed to deploy my Spring Boot application. For this I used the web console. I imported my project from GitLab, and chose the Java 8 image builder. However, using this method, I didn't find a way to launch my application by associating the java-agent elastic-apm-agent.

Locally, I run this command to start my application:

mvn package && java -javaagent:elastic-apm-agent/elastic-apm-agent-1.26.0.jar \
-Delastic.apm.service_name=ms-salarie \
-Delastic.apm.server_urls=http://localhost:8200 \
-Delastic.apm.secret_token= \
-Delastic.apm.environment=development \
-Delastic.apm.application_packages=com.leanerp.salarie \
-Delastic.apm.config_file=elastic-apm-agent/elasticapm.properties \
-jar target/salarie-1.1.3-SNAPSHOT.jar

Is there a way to override the command launched by the container of my application? Or another solution allowing me to use the elastic-apm-agent?

I am a newbie on OpenShift, so I don't fully understand all the concepts.


Solution

  • Ok, so the answer was adding this environment variable :

    JAVA_OPTS_APPEND=-javaagent:{{path_to_elastic_apm_agent}}
    

    this command allows you to launch your java application with options.