# JMX fields through LogStash

**URL:** https://discuss.elastic.co/t/jmx-fields-through-logstash/152545
**Category:** Logstash
**Created:** [October 15, 2018, 5:52pm UTC](https://discuss.elastic.co/t/jmx-fields-through-logstash/152545 "2018-10-15T17:52:38Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Vishnu59](https://avatars.discourse-cdn.com/v4/letter/v/8c91f0/32.png) [@Vishnu59](https://discuss.elastic.co/u/Vishnu59)
#### Post date: [October 15, 2018, 5:52pm UTC](https://discuss.elastic.co/t/jmx-fields-through-logstash/152545/1 "2018-10-15T17:52:38Z")

</div>

Hi There,

I have setup JMX monitoring for one of our Java applications, using Logstash JMX plugin. Everything works as expected but one thing am hoping for is the way key value pair is being created. Right now after gets pushed to Elasticsearch, this is how the key value pair looks

metric\_path: kafka.ReplicaManager.FifteenMinuteRate  
metric\_value\_number: 0

What am hoping to have it stored like is below  
kafka.ReplicaManager.FifteenMinuteRate: 0

This way, I would like to remove metric\_path and metric\_value\_number fields and make the real key, value pair show as is.

Can you please suggest if there is a way I can do that?

Thanks,

Vishnu

---

<div class="post-metadata">

### Author: ![Vishnu59](https://avatars.discourse-cdn.com/v4/letter/v/8c91f0/32.png) [@Vishnu59](https://discuss.elastic.co/u/Vishnu59)
#### Post date: [October 15, 2018, 5:57pm UTC](https://discuss.elastic.co/t/jmx-fields-through-logstash/152545/2 "2018-10-15T17:57:23Z")

</div>

Just an FYI, this is how my conf file looks right now

{  
"host" : "172.24.24.150",  
"port" : 15000,  
"alias" : "kafka",  
"queries" : [  
{  
"object\_name" : "java.lang:type=Memory",  
"object\_alias" : "Memory"  
}, {  
"object\_name" : "java.lang:type=Threading",  
"object\_alias" : "Threading"  
}, {  
"object\_name" : "java.lang:type=Runtime",  
"object\_alias" : "Runtime"  
}, {  
"object\_name" : "kafka.server:type=ReplicaManager,name=FailedIsrUpdatesPerSec",  
"object\_alias" : "ReplicaManager"  
}]  
}

---

<div class="post-metadata">

### Author: ![Makra](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@Makra](https://discuss.elastic.co/u/Makra)
#### Post date: [October 16, 2018, 5:09am UTC](https://discuss.elastic.co/t/jmx-fields-through-logstash/152545/3 "2018-10-16T05:09:13Z")

</div>

You need to write a ruby filter to format the JMX parameters and their values .

```
 ruby {

         code => "

         Metric_Path = event.get('metric_path');
         Metric_Value_Number = event.get('metric_value_number');

          if Metric_Path.eql?('kafka.ReplicaManager.FifteenMinuteRate')
            event.set('kafka.ReplicaManager.FifteenMinuteRate, Metric_Value_Number);
         end

         "
      }

```

Once the desired field is added, you can remove `metric_path` and `metric_value_number` from the message using drop.

---

<div class="post-metadata">

### Author: ![Vishnu59](https://avatars.discourse-cdn.com/v4/letter/v/8c91f0/32.png) [@Vishnu59](https://discuss.elastic.co/u/Vishnu59)
#### Post date: [October 16, 2018, 4:54pm UTC](https://discuss.elastic.co/t/jmx-fields-through-logstash/152545/4 "2018-10-16T16:54:14Z")

</div>

Thank you very much Makra, I did this and see data being stored as expected.

Thanks,

Vishnu

---

<div class="post-metadata">

### Author: ![Makra](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@Makra](https://discuss.elastic.co/u/Makra)
#### Post date: [October 17, 2018, 2:55am UTC](https://discuss.elastic.co/t/jmx-fields-through-logstash/152545/5 "2018-10-17T02:55:17Z")

</div>

Hi visnu, I will appreciate if you mark it as a solved.

---

<div class="post-metadata">

### Author: ![Vishnu59](https://avatars.discourse-cdn.com/v4/letter/v/8c91f0/32.png) [@Vishnu59](https://discuss.elastic.co/u/Vishnu59)
#### Post date: [October 18, 2018, 6:03pm UTC](https://discuss.elastic.co/t/jmx-fields-through-logstash/152545/6 "2018-10-18T18:03:52Z")

</div>

Thank you again Makra and I just took care of that!!

---

<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: [November 15, 2018, 6:03pm UTC](https://discuss.elastic.co/t/jmx-fields-through-logstash/152545/7 "2018-11-15T18:03:55Z")

</div>

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