Logstash-input-jmx new feature proposal

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 }
  • 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|
    @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])
    @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)
    rescue Exception => ex
    @logger.warn("Failed retrieving metrics for operation #{operation} on object #{jmx_object_name.object_name}")

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.


1 Like

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