# Elastic APM Java Agent JMX

**URL:** https://discuss.elastic.co/t/elastic-apm-java-agent-jmx/308527
**Category:** APM
**Tags:** java
**Created:** [June 30, 2022, 1:34am UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-jmx/308527 "2022-06-30T01:34:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![aravind0910](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aravind0910/32/107754_2.png) [@aravind0910](https://discuss.elastic.co/u/aravind0910)
#### Post date: [June 30, 2022, 1:34am UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-jmx/308527/1 "2022-06-30T01:34:46Z")

</div>

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text 🙂

TIP 1: select at least one tag that further categorizes your topic. For example `server` for APM Server related questions, `java` for questions regarding the Elastic APM Java agent, or `ui` for questions about the APM App within Kibana.

TIP 2: Check out the [troubleshooting guide](https://www.elastic.co/guide/en/apm/get-started/current/troubleshooting.html) first. Not only will it help you to resolve common problems faster but it also explains in more detail which information we need before we can properly help you.

**Kibana version** : 7.16.3

**Elasticsearch version** : 7.16.3

**APM Server version** : 7.16.3

**APM Agent language and version** : Java Agent; Version: 1.32.0

**Browser version** :

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**:

**Fresh install or upgraded from other version?**  
Fresh Install

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.  
No

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

```auto
I'm trying to configure JMX metric collection in the Elastic APM Java agent. I configured the capture_jmx_metrics option in elasticapm.properties as follows:
    capture_jmx_metrics=[object_name[java.lang:type=Memory] attribute[HeapMemoryUsage:metric_name=heap] ] 

I get the following error:
2022-06-30 01:31:13,197 [elastic-apm-configuration-reloader] WARN org.stagemonitor.configuration.ConfigurationOption - Error in /opt/app/bbnmsls/ol/config/bbnmsls-elasticapm.properties: Empty key at pos 1 in '[object_name[java.lang:type=Memory] attribute[HeapMemoryUsage:metric_name=heap] ]' Default value '' for 'capture_jmx_metrics' will be applied.

I also tried using the below json format, which resulted in the same error:
  capture_jmx_metrics=[ \
    {"object_name": "java.lang:type=GarbageCollector,name=*", "attribute": "CollectionCount", "metric_name": "collection_count"}, \
    {"object_name": "java.lang:type=GarbageCollector,name=*", "attribute": "CollectionTime"} \
  ]

```

**Steps to reproduce** :

1. enable capture\_jmx\_metrics in elasticapm.properties
2. 
3. 

**Errors in browser console (if relevant)**:

**Provide logs and/or server output (if relevant)**:

---

<div class="post-metadata">

### Author: ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)
#### Post date: [June 30, 2022, 7:18am UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-jmx/308527/2 "2022-06-30T07:18:52Z")

</div>

Hi @aravind0910 ,

The syntax is not correct in your configuration properties, it should be replaced by:

```auto
capture_jmx_metrics=object_name[java.lang:type=Memory] attribute[HeapMemoryUsage:metric_name=heap]

```

Also, for extra clarity I suggest using the multi-line syntax when there are multiple objects and attributes:

```auto
capture_jmx_metrics=\
object_name[java.lang:type=Memory] \
attribute[HeapMemoryUsage:metric_name=heap] \
attribute[NonHeapMemoryUsage:metric_name=nonheap] \
, \
object_name[java.lang:type=Threading] \
attribute[ThreadCount:metric_name=thread_count] \

```

---

<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: [July 21, 2022, 3:19am UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-jmx/308527/3 "2022-07-21T03:19:31Z")

</div>

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