JMX fields through LogStash

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?



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

"host" : "",
"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"

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);


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

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



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

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

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