# Setting schedule for logstash jmx input

**URL:** https://discuss.elastic.co/t/setting-schedule-for-logstash-jmx-input/185314
**Category:** Logstash
**Created:** [June 12, 2019, 3:26am UTC](https://discuss.elastic.co/t/setting-schedule-for-logstash-jmx-input/185314 "2019-06-12T03:26:13Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)
#### Post date: [June 12, 2019, 3:26am UTC](https://discuss.elastic.co/t/setting-schedule-for-logstash-jmx-input/185314/1 "2019-06-12T03:26:14Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/f/efe50eb2a432d78e679fa5afb1171b981c83d0ac.png)  
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](https://us1.discourse-cdn.com/elastic/original/3X/9/4/9420e09dcd14c29380441bf19bcb683d2647592e.png)  
what type can i define for "info" field?

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [June 12, 2019, 2:57pm UTC](https://discuss.elastic.co/t/setting-schedule-for-logstash-jmx-input/185314/2 "2019-06-12T14:57:52Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)
#### Post date: [June 18, 2019, 6:05am UTC](https://discuss.elastic.co/t/setting-schedule-for-logstash-jmx-input/185314/3 "2019-06-18T06:05:48Z")

</div>

many thanks.

---

<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: [July 16, 2019, 6:05am UTC](https://discuss.elastic.co/t/setting-schedule-for-logstash-jmx-input/185314/4 "2019-07-16T06:05:49Z")

</div>

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