# How to get JVM Memory used with metricbeat jolokia module

**URL:** https://discuss.elastic.co/t/how-to-get-jvm-memory-used-with-metricbeat-jolokia-module/267828
**Category:** Beats
**Tags:** metricbeat
**Created:** [March 19, 2021, 3:25pm UTC](https://discuss.elastic.co/t/how-to-get-jvm-memory-used-with-metricbeat-jolokia-module/267828 "2021-03-19T15:25:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![wifi](https://avatars.discourse-cdn.com/v4/letter/w/f05b48/32.png) [@wifi](https://discuss.elastic.co/u/wifi)
#### Post date: [March 19, 2021, 3:25pm UTC](https://discuss.elastic.co/t/how-to-get-jvm-memory-used-with-metricbeat-jolokia-module/267828/1 "2021-03-19T15:25:29Z")

</div>

I'm trying to use Jolokia + metricbeat to gather Info about the JVM Memory.

I did everything like described in the docs but it won't work. [Jolokia jmx metricset | Metricbeat Reference [7.11] | Elastic](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-metricset-jolokia-jmx.html#_accessing_jolokia_via_post_or_get_method)

```
  jmx.mappings:
- mbean: 'java.lang:type=Memory'
  attributes:
   - attr: HeapMemoryUsage
     field: memory.heap_usage
   - attr: NonHeapMemoryUsage
     field: memory.non_heap_usage

```

I can collect other JMX metrics thou. Does anybody know how to solve this issue? I'm using latest jolokia with latest elastic stack

I already tried downgrading Jolokia to 1.5

---

<div class="post-metadata">

### Author: ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)
#### Post date: [March 22, 2021, 9:56am UTC](https://discuss.elastic.co/t/how-to-get-jvm-memory-used-with-metricbeat-jolokia-module/267828/2 "2021-03-22T09:56:36Z")

</div>

Hi!

If you `curl` to the jolokia endpoint will you see this metric? You need to verify that your jolokia agent provides it and with what labels.

Also please check if Metricbeat reports any errors.

---

<div class="post-metadata">

### Author: ![wifi](https://avatars.discourse-cdn.com/v4/letter/w/f05b48/32.png) [@wifi](https://discuss.elastic.co/u/wifi)
#### Post date: [March 22, 2021, 11:40am UTC](https://discuss.elastic.co/t/how-to-get-jvm-memory-used-with-metricbeat-jolokia-module/267828/3 "2021-03-22T11:40:02Z")

</div>

Calling that endpoint with curl yields the expected result and metricbeat does not report any errors

---

<div class="post-metadata">

### Author: ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)
#### Post date: [March 23, 2021, 8:41am UTC](https://discuss.elastic.co/t/how-to-get-jvm-memory-used-with-metricbeat-jolokia-module/267828/4 "2021-03-23T08:41:38Z")

</div>

Did you run Metribeat in debug mode? (`./metricbeat -e -d "*"`) please only add the specific `mbean` in the config so as to have less noise and check if logs can give us anything useful.

---

<div class="post-metadata">

### Author: ![wifi](https://avatars.discourse-cdn.com/v4/letter/w/f05b48/32.png) [@wifi](https://discuss.elastic.co/u/wifi)
#### Post date: [April 12, 2021, 6:49am UTC](https://discuss.elastic.co/t/how-to-get-jvm-memory-used-with-metricbeat-jolokia-module/267828/5 "2021-04-12T06:49:33Z")

</div>

With your advice we could trace the problem further. Apart from deactivating the unrelevant mbeans, we also deactivated other modules like 'system'. After that we could clearly see that the data is sent without an issue.

Checking the Logs of Logstash we figured that it was not able to ingest the data due to an error in an elasticsearch pipeline.

I wrote this pipeline a while ago to extract useful information from the `mbean` field. Sadly this field did not exist in the jmx metrics JVM memory. I changed the pipeline to ignore the absence of the field `mbean` and it started working for a while.

I found another issue but did not analyze it further. We are only interested in the attribute `HeapMemoryUsage`. Configuring it properly did not yield any data. It only starts working after configuring the attribute `NonHeapMemoryUsage` additionally.

---

<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: [May 10, 2021, 8:49am UTC](https://discuss.elastic.co/t/how-to-get-jvm-memory-used-with-metricbeat-jolokia-module/267828/6 "2021-05-10T08:49:46Z")

</div>

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