Setting schedule for logstash jmx input

hi all,
I am using jmx input plugin to ship MBeans into elasticsearch. logstash get the value of each defined attribute as a separate event. in order to gather the value of same attributes in one event the aggregate filter has been used. the logstash config file is as following:

input {
jmx {
  path => "C:\logstash\jmxconf"
  polling_frequency => 10
  type => "jmx"
  nb_thread => 4
}
}
filter {
mutate {
            split => ["metric_path", "."]
			add_field => { "jmx_path" => "%{metric_path[1]}" }
			add_field => { "jmx_att1" => "%{metric_path[2]}" }
			add_field => { "jmx_att2" => "%{metric_path[3]}" }
}
if "Memory" in [jmx_path] {
mutate {
            add_field => { "jmx_att3" => "%{jmx_att1}_%{jmx_att2}" }
}
}
else {
mutate {
            add_field => { "jmx_att3" => "%{jmx_att1}" }
}
}
 aggregate {
    task_id => "%{jmx_path}"
    code => "
 map['jmx_path'] = event.get('jmx_path')
         map['Info'] ||= []
         map['Info'] << {event.get('jmx_att3') => event.get('metric_value_number')}
         event.cancel()
		 "
      push_previous_map_as_event => true
       timeout => 10 
	   }
}
output {
  elasticsearch { 
    hosts => ["http://localhost:9200"]
    index => "agtest11_%{+YYYY.MM.dd}"
 }
  stdout { codec => rubydebug }
}

where the jmx config file in "C:\logstash\jmxconf" directory is as following:

{
  "host" : "localhost",
  "port" : 2222,
  "alias" : "ss",
  "queries" : [
  {
    "object_name" : "java.lang:type=Memory",
	"attributes" : [ "HeapMemoryUsage", "NonHeapMemoryUsage" ],
    "object_alias" : "Memory"
  },{
    "object_name" : "java.lang:type=Threading",
	"attributes" : [ "ThreadCount", "TotalStartedThreadCount","DaemonThreadCount","PeakThreadCount" ],
    "object_alias" : "Threading"
  },{
    "object_name" : "com.bea:ServerRuntime=MS1,Name=MS1,Type=JVMRuntime",
    "attributes" : [ "HeapFreePercent" ],
    "object_alias" : "Heap"
  }]
}

the output is as following:


where two "Memory" jmx_path should be merged and should be as following in one record:

{{
  "HeapMemoryUsage_init": 268435456
},
{
  "HeapMemoryUsage_max": 512229376
},
{
  "HeapMemoryUsage_used": 109426424
},
{
  "HeapMemoryUsage_committed": 512229376
},
{
  "NonHeapMemoryUsage_committed": 165306368
},
{
  "NonHeapMemoryUsage_init": 2555904
},
{
  "NonHeapMemoryUsage_max": -1
},
{
  "NonHeapMemoryUsage_used": 162696464
}
}

how can i handle this issue?
In addition following message can be found in Kibana:
image
what type can i define for "info" field?

You have a Memory event, followed by a Threading event, followed by several Memory events. You have enabled push_previous_map_as_event which tells the aggregate to create a new event every time it sees a new task_id. Try push_map_as_event_on_timeout, and I would make the timeout 1 less then the polling interval.

many thanks.

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