# Java APM agent can't create JMX metric

**URL:** https://discuss.elastic.co/t/java-apm-agent-cant-create-jmx-metric/232284
**Category:** APM
**Tags:** java
**Created:** [May 12, 2020, 5:54pm UTC](https://discuss.elastic.co/t/java-apm-agent-cant-create-jmx-metric/232284 "2020-05-12T17:54:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Marcus\_Simonsen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcus_simonsen/32/54552_2.png) [@Marcus\_Simonsen](https://discuss.elastic.co/u/Marcus_Simonsen)
#### Post date: [May 12, 2020, 5:54pm UTC](https://discuss.elastic.co/t/java-apm-agent-cant-create-jmx-metric/232284/1 "2020-05-12T17:54:50Z")

</div>

**Kibana version** : 7.5.1

**Elasticsearch version** : 7.5.1

**APM Server version** : 7.6.2

**APM Agent language and version** : java 1.15.0

**Browser version** : NA

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

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

I am instrumenting a custom load application (not spring boot, jboss/tomcat etc).  
I've attempted to add in instrumentation packages as well as JMX information:  
apmelastic.properties:

```auto
capture_jmx_metrics=object_name[java.lang:type=GarbageCollector,name=*] attribute[CollectionCount:metric_name=collection_count] attribute[CollectionTime], object_name[kafka.producer:type=producer-metrics,client-id=AuditLoad] attribute[request-latency-avg] 

```

**Steps to reproduce** :

1. Start elasticsearch, kibana
2. ./apmserver setup
3. java -jar app.jar -javaagent $path\_to\_jar

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

```auto
2020-05-12 12:01:15.133 [main] WARN co.elastic.apm.agent.jmx.JmxMetricTracker - Can't create metric 'object_name[kafka.producer:type=producer-metrics,client-id=AuditLoad] attribute[request-latency-avg]' because attribute 'request-latency-avg' could not be found

```

That's one of the many warnings printed during startup, and I know that the Kafka metrics exist for that name (confirmed with jconsole) - but likely registered lazily.  
I'm not getting any transactions in Kibana either, but I wanted to track down the JMX issues first.

---

<div class="post-metadata">

### Author: ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)
#### Post date: [May 13, 2020, 6:46am UTC](https://discuss.elastic.co/t/java-apm-agent-cant-create-jmx-metric/232284/2 "2020-05-13T06:46:00Z")

</div>

We do add listeners so that lazily added MBeans get captured, too. However, when they're not available on startup, you'll see this warning. Do you get any data, for example heap metrics from your application? If not, there might be a connection issue between the agent and APM Server.

---

<div class="post-metadata">

### Author: ![Marcus\_Simonsen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcus_simonsen/32/54552_2.png) [@Marcus\_Simonsen](https://discuss.elastic.co/u/Marcus_Simonsen)
#### Post date: [May 13, 2020, 12:09pm UTC](https://discuss.elastic.co/t/java-apm-agent-cant-create-jmx-metric/232284/3 "2020-05-13T12:09:09Z")

</div>

The garbage collection count, "collection\_count" is making it's way to Elastic in apm indices. So I don't think it's connectivity issues.

---

<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: [June 3, 2020, 8:09am UTC](https://discuss.elastic.co/t/java-apm-agent-cant-create-jmx-metric/232284/4 "2020-06-03T08:09:18Z")

</div>

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