# Logstash-input-jmx new feature proposal

**URL:** https://discuss.elastic.co/t/logstash-input-jmx-new-feature-proposal/31388
**Category:** Logstash
**Created:** [September 30, 2015, 9:11am UTC](https://discuss.elastic.co/t/logstash-input-jmx-new-feature-proposal/31388 "2015-09-30T09:11:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![graziano1955](https://avatars.discourse-cdn.com/v4/letter/g/e480ec/32.png) [@graziano1955](https://discuss.elastic.co/u/graziano1955)
#### Post date: [September 30, 2015, 9:11am UTC](https://discuss.elastic.co/t/logstash-input-jmx-new-feature-proposal/31388/1 "2015-09-30T09:11:25Z")

</div>

Hi,  
I used the JMX plugin to capture data from a WSO2 platform nodes, reading the attributes exposed by their JMX Beans.

But not all data can be captured reading attributes, many data can be read only invoking specific methods and passing parameters.

So I investigated the JMX plugin (I know Java, C++, Delphi, ecc. but I dont know Ruby) and I saw that the plugin use a component developed by Jeff Mesnil in 2007 which interfaces the Java JMX components. This component supports attributes but also operations (methods).

So i tried to implement the operations support in JMX plugin and for some reason (I don't know Ruby!) now I am able to capture data from operations invocation.

I hope this can be a little contribution to the JMX plugin authors and possibly a new featura in the next plugin release.

CHANGES in jmx.rb:

- added in validate\_configuration:  
_if query.has\_key?("operations") && !query["operations"].respond\_to?(:each)_  
_validation\_errors \<\< BAD\_TYPE\_QUERY\_PARAMETER % { :param =\> 'operations', :index =\> index, :expected =\> Enumerable, :actual =\> query['operations'].class }_  
_end_
- added in thread\_jmx:  
_if query.has\_key?('operations')_  
_@logger.debug("Retrieves operations #{query['operations']} to #{jmx\_object\_name.object\_name}")_  
_query['operations'].each do |operation|_  
_begin_  
@logger.debug("operation: #{operation[0]} params: #{operation[1].join(', ')}")  
\*jmx\_operation\_value = jmx\_object\_name.send(operation[0], _operation[1])_  
_if jmx\_operation\_value.instance\_of? Java::JavaxManagementOpenmbean::CompositeDataSupport_  
_@logger.debug('The jmx value is a composite\_data one')_  
_jmx\_operation\_value.each do |jmx\_operation\_value\_composite|_  
_@logger.debug("Get jmx value #{jmx\_operation\_value[jmx\_operation\_value\_composite]} for operation #{operation}.#{jmx\_operation\_value\_composite} to #{jmx\_object\_name.object\_name}")_  
_send\_event\_to\_queue(queue, thread\_hash\_conf['host'], "#{base\_metric\_path}.#{object\_name}.#{operation}.#{jmx\_operation\_value\_composite}", jmx\_operation\_value[jmx\_operation\_value\_composite])_  
_end_  
_else_  
_@logger.debug("Get jmx value #{jmx\_operation\_value} for operation #{operation} to #{jmx\_object\_name.object\_name}")_  
_send\_event\_to\_queue(queue, thread\_hash\_conf['host'], "#{base\_metric\_path}.#{object\_name}.#{operation}", jmx\_operation\_value)_  
_end_  
_rescue Exception =\> ex_  
_@logger.warn("Failed retrieving metrics for operation #{operation} on object #{jmx\_object\_name.object\_name}")_  
_@logger.warn(ex.message)_  
_end_  
_end_  
_end_

CHANGES in jmx configuration:

......  
_{_  
_"object\_name" : "java.lang:type=Threading",_  
_"attributes" : ["ThreadCount", "TotalStartedThreadCount", "DaemonThreadCount", "PeakThreadCount"],_  
_"object\_alias" : "Threading"_  
_}, {_  
_"object\_name" : "org.wso2.carbon:type=StatisticsAdmin",_  
_"operations" : [_  
_["getServiceRequestCount", ["MMGQueryPazienteProxy"]],_  
_["getServiceFaultCount", ["MMGQueryPazienteProxy"]],_  
["getServiceResponseCount", ["MMGQueryPazienteProxy"]],   
_["getOperationRequestCount", ["MMGQueryPazienteProxy", "QueryPaziente"]],_  
_["getOperationFaultCount", ["MMGQueryPazienteProxy", "QueryPaziente"]],_  
["getOperationResponseCount", ["MMGQueryPazienteProxy", "QueryPaziente"]]  
],  
_"object\_alias" : "StatisticsAdmin"_  
_} ]_

Operations is an array of jmx operations.  
Each array element has as the first element the operation name and as the second element an array of parameters.

Graziano

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [September 30, 2015, 9:18am UTC](https://discuss.elastic.co/t/logstash-input-jmx-new-feature-proposal/31388/2 "2015-09-30T09:18:21Z")

</div>

It'd be worth raising this as a feature request [https://github.com/logstash-plugins/logstash-input-jmx](https://github.com/logstash-plugins/logstash-input-jmx)

---

<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 6, 2017, 5:27am UTC](https://discuss.elastic.co/t/logstash-input-jmx-new-feature-proposal/31388/3 "2017-07-06T05:27:40Z")

</div>


