# Configure APM to collect jmx metrics

**URL:** https://discuss.elastic.co/t/configure-apm-to-collect-jmx-metrics/281646
**Category:** APM
**Tags:** java
**Created:** [August 17, 2021, 8:33am UTC](https://discuss.elastic.co/t/configure-apm-to-collect-jmx-metrics/281646 "2021-08-17T08:33:52Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Jalil](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@Jalil](https://discuss.elastic.co/u/Jalil)
#### Post date: [August 17, 2021, 8:33am UTC](https://discuss.elastic.co/t/configure-apm-to-collect-jmx-metrics/281646/1 "2021-08-17T08:33:53Z")

</div>

Dear all,

Since some days ago, I'm trying to collect jmx metrics from java app and index them to ES in order to visualize them in kibana but without any result.

APM is already configured but it don't give me all metrics. I think that it is possible to add jmx metrics to APM.  
Could someone help me to configure apm collecting jmx metrics ? I'm not able to find where to configure apm and whish file should be modified to collect jmx metrics.

Thank you  
Jalil

---

<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: [August 17, 2021, 9:15am UTC](https://discuss.elastic.co/t/configure-apm-to-collect-jmx-metrics/281646/2 "2021-08-17T09:15:14Z")

</div>

Please go over all [possible ways to configure the Java agent](https://www.elastic.co/guide/en/apm/agent/java/current/configuration.html#configuration) and pick the one that is most suitable for you.

Once you have that in place, you can use the [`capture_jmx_metrics`](https://www.elastic.co/guide/en/apm/agent/java/current/config-jmx.html#config-capture-jmx-metrics) config option. It's not the most trivial one to use, but its documentation is quite comprehensive. It may still require some trial-and-error, so maybe setting the [`log_level`](https://www.elastic.co/guide/en/apm/agent/java/current/config-logging.html#config-log-level) to `DEBUG` can be useful until you get it right.

I hope this helps.

---

<div class="post-metadata">

### Author: ![Jalil](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@Jalil](https://discuss.elastic.co/u/Jalil)
#### Post date: [August 17, 2021, 2:48pm UTC](https://discuss.elastic.co/t/configure-apm-to-collect-jmx-metrics/281646/3 "2021-08-17T14:48:31Z")

</div>

Thnak you for your help.  
I'm using the **System properties** like this :

```auto
-javaagent:Path\to\elastic-apm-agent-1.17.0.jar
-Delastic.apm.service_name=NameOfService
-Delastic.apm.server_urls=http://hostName:8200
-Delastic.apm.application_packages=app_packages

```

Now in this config, how can I add the jmx capture config ?

---

<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: [August 18, 2021, 4:41am UTC](https://discuss.elastic.co/t/configure-apm-to-collect-jmx-metrics/281646/4 "2021-08-18T04:41:07Z")

</div>

Then use it the same, for example:

```auto
-Delastic.apm.capture_jmx_metrics="object_name[java.lang:type=GarbageCollector,name=*] attribute[CollectionCount:metric_name=collection_count] attribute[CollectionTime]"

```

---

<div class="post-metadata">

### Author: ![Jalil](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@Jalil](https://discuss.elastic.co/u/Jalil)
#### Post date: [August 18, 2021, 9:15am UTC](https://discuss.elastic.co/t/configure-apm-to-collect-jmx-metrics/281646/5 "2021-08-18T09:15:34Z")

</div>

Hello,  
thank you for your great help, it works 🙂

---

<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: [September 15, 2021, 9:15am UTC](https://discuss.elastic.co/t/configure-apm-to-collect-jmx-metrics/281646/6 "2021-09-15T09:15:47Z")

</div>

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