How to do monitor third part applications using elastic APM

I'm using Cloud Instance and all the version are the latest.
NOTE: This is a trail version hosted on AWS.

We are using external application -->Gerrit and we would like to know how to use the Elastic APM to monitor the application which is not built by us.

Can elastic run APM on applications which are not developed by the company and only hosted by us????

The documentation states the following but when i do it it simpley fails to start the application

https://prodtest.kb.europe-west3.gcp.cloud.es.io:9243/app/home#/tutorial/apm

*************
[root@awsmblx108as602 bin]# java -javaagent:/tmp/elastic-apm-agent-1.26.0.jar \
> -Delastic.apm.service_name=gerrit \
> -Delastic.apm.server_urls=https://e8544a56748c4b109e421b4b5da78319.apm.europe-west3.gcp.cloud.es.io:443 \
> -Delastic.apm.secret_token=kN8ZVOd99TDcRMSWqm \
> -Delastic.apm.environment=production \
> -Delastic.apm.application_packages=org.example \
> -jar /data/gerrit/bin/gerrit.war
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
2021-10-07 12:43:37,633 [main] INFO  co.elastic.apm.agent.util.JmxUtils - Found JVM-specific OperatingSystemMXBean interface: com.sun.management.OperatingSystemMXBean
2021-10-07 12:43:37,663 [main] INFO  co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.26.0 as gerrit on Java 11.0.10 Runtime version: 11.0.10+8-LTS-162 VM version: 11.0.10+8-LTS-162 (Oracle Corporation) Linux 4.18.0-305.3.1.el8_4.x86_64
2021-10-07 12:43:37,663 [main] INFO  co.elastic.apm.agent.configuration.StartupInfo - service_name: 'gerrit' (source: Java System Properties)
2021-10-07 12:43:37,663 [main] INFO  co.elastic.apm.agent.configuration.StartupInfo - environment: 'production' (source: Java System Properties)
2021-10-07 12:43:37,664 [main] INFO  co.elastic.apm.agent.configuration.StartupInfo - secret_token: 'XXXX' (source: Java System Properties)
2021-10-07 12:43:37,664 [main] INFO  co.elastic.apm.agent.configuration.StartupInfo - server_urls: 'https://e8544a56748c4b109e421b4b5da78319.apm.europe-west3.gcp.cloud.es.io:443' (source: Java System Properties)
2021-10-07 12:43:37,664 [main] INFO  co.elastic.apm.agent.configuration.StartupInfo - application_packages: 'org.example' (source: Java System Properties)
2021-10-07 12:43:38,621 [main] INFO  co.elastic.apm.agent.impl.ElasticApmTracer - Tracer switched to RUNNING state
Gerrit Code Review
usage: java -jar gerrit.war command [ARG ...]

The most commonly used commands are:
  init            Initialize a Gerrit installation
  reindex         Rebuild the secondary index
  daemon          Run the Gerrit network daemons
  version         Display the build version number
  passwd          Set or change password in secure.config

  ls              List files available for cat
  cat FILE        Display a file from the archive

**********************

At the end we would like to monitor applications hosted by us and not developed by us and can Elastic help us achieve it,................If not in the free atleast the paid version??

Thank you,
Anish

from the look of the error you pasted there, you are failing to add an argument to the gerrit startup, ie it is saying that your startup command needs to be

java -javagent... ... -jar /data/gerrit/bin/gerrit.war COMMAND

where you need to replace COMMAND with one of those gerrit commands listed (like daemon). Gerrit is terminating because you haven't given it an argument.

Please reset your secret token, as this a public forum so the token you've pasted is now public

We start and stop gerrit as a service.............How do we use that to monitor gerrit using elastic and APM???
Also some of our applications are docker based so how do we use that to integrate elastic APM with docker...........For ex: docker compose up and docker compose down???

systemctl stop gerrit.service
systemctl start gerrit.service

Also, does it inject anything.

Manually if we were to start gerrit we simply run the below command.

/data/gerrit/bin/gerrit.sh start
/data/gerrit/bin/gerrit.sh stop

In this case, you have several options, for example

  • edit your gerrit.sh script so that the command line running the app (... -jar /data/gerrit/bin/gerrit.war COMMAND) includes those additional command line arguments (javaagent and the config options provided as system properties like the -Delastic.apm.XXX ones in your example above).
  • edit your Dockerfile so that the agent and configs are provided as environment variables:
    • Use ENV JAVA_TOOL_OPTIONS=-javaagent:/path/to/elastic-apm-gent.jar for the agent attachment
    • Use ENV ELASTIC_APM_XXX=<config-value> for config options, e.g. ENV ELASTIC_APM_SERVER_URLS=https://e8544a56748c4b109e421b4b5da78319.apm.europe-west3.gcp.cloud.es.io:443

Either way, you will have to edit your Dockerfile so that it downloads the agent from maven central (e.g. Central Repository: co/elastic/apm/elastic-apm-agent/1.26.0) and store it in your Docker image so that your -javaagent argument refers to a local location within the container.

Lastly, you will have to setup your container so that the APM Server is accessible to it.

I hope this helps.
Good luck!