# How to do monitor third part applications using elastic APM

**URL:** <https://discuss.elastic.co/t/how-to-do-monitor-third-part-applications-using-elastic-apm/286131>\
**Category:** APM\
**Tags:** java\
**Created:** [October 7, 2021, 12:47pm UTC](https://discuss.elastic.co/t/how-to-do-monitor-third-part-applications-using-elastic-apm/286131 "2021-10-07T12:47:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnishAnil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anishanil/32/95547_2.png) [@AnishAnil](https://discuss.elastic.co/u/AnishAnil)\
**Post date:** [October 7, 2021, 12:47pm UTC](https://discuss.elastic.co/t/how-to-do-monitor-third-part-applications-using-elastic-apm/286131/1 "2021-10-07T12:47:19Z")

</div>

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](https://prodtest.kb.europe-west3.gcp.cloud.es.io:9243/app/home#/tutorial/apm)

```auto
*************
[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

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [October 7, 2021, 2:04pm UTC](https://discuss.elastic.co/t/how-to-do-monitor-third-part-applications-using-elastic-apm/286131/2 "2021-10-07T14:04:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AnishAnil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anishanil/32/95547_2.png) [@AnishAnil](https://discuss.elastic.co/u/AnishAnil)\
**Post date:** [October 8, 2021, 10:02am UTC](https://discuss.elastic.co/t/how-to-do-monitor-third-part-applications-using-elastic-apm/286131/3 "2021-10-08T10:02:38Z")

</div>

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???

---

<div class="post-metadata">

**Author:** ![AnishAnil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anishanil/32/95547_2.png) [@AnishAnil](https://discuss.elastic.co/u/AnishAnil)\
**Post date:** [October 8, 2021, 10:04am UTC](https://discuss.elastic.co/t/how-to-do-monitor-third-part-applications-using-elastic-apm/286131/4 "2021-10-08T10:04:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 10, 2021, 2:19pm UTC](https://discuss.elastic.co/t/how-to-do-monitor-third-part-applications-using-elastic-apm/286131/5 "2021-10-10T14:19:56Z")

</div>

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](https://repo1.maven.org/maven2/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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 31, 2021, 10:20am UTC](https://discuss.elastic.co/t/how-to-do-monitor-third-part-applications-using-elastic-apm/286131/6 "2021-10-31T10:20:15Z")

</div>

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