Search code examples
javalogstashjmxactivemq-artemis

ActiveMQ Artemis and Logstash JMX input


I want to monitor ActiveMQ Artemis from JMX using logstash and ship data to Elastic.

For Artemis 2.13.0,

management.xml:

  • commented out the <authorisation> tag
  • added <connector connector-port="1099">

artemis.profile.cmd:

  • added -Djava.rmi.server.hostname=localhost under JAVA_ARGS, since the Jconsole/Logstash was not able to discover the RMI JMX

Set ELK in my local windows 10 machine local-jmx.config

input {
  jmx {
    path => "/path/to/config/"  //This has a file jmxquery.config
    polling_frequency => 60
    nb_thread => 5
    type => "jmx"
  }
}
output {
    elasticsearch {
        hosts => [ "localhost:9200" ]
    }
}

jmxquery.config :

{
  "host" : "127.0.0.1",
  "port" : 1099,
  "url": "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi",
  "username" : "guest",
  "password" : "guest",
   "alias" : "Version",
  "queries" : [
  {
    "object_name" :  "org.apache.activemq.artemis:broker=0.0.0.0,attribute=Version" ,
    "object_alias" : "version"
  } 
 ]
}

I am able to use localhost:1099 with JConsole

jconsole local

However, when I start logstash the JMX is able to connect but there is a message saying, "No jmx object."

[2020-07-29T13:57:40,030][DEBUG][logstash.inputs.jmx      ] Wait until the queue conf is empty
[2020-07-29T13:57:40,030][DEBUG][logstash.inputs.jmx      ] Retrieve config {"host"=>"127.0.0.1", "port"=>1099, "url"=>"service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi", "username"=>"guest", "password"=>"guest", "alias"=>"ActiveMQ", "queries"=>[{"object_name"=>"org.apache.activemq.artemis:broker=0.0.0.0,attribute=Version", "object_alias"=>"version"}]} from queue conf
[2020-07-29T13:57:40,031][DEBUG][logstash.inputs.jmx      ] Check if jmx connection need a user/password
[2020-07-29T13:57:40,031][DEBUG][logstash.inputs.jmx      ] Wait 60s (60-0(seconds wait until queue conf empty)) before to launch again a new jmx metrics collection
[2020-07-29T13:57:40,031][DEBUG][logstash.inputs.jmx      ] Connect to 127.0.0.1:1099 with user guest
[2020-07-29T13:57:40,044][DEBUG][logstash.inputs.jmx      ] Set base_metric_path to alias: Version
[2020-07-29T13:57:40,044][DEBUG][logstash.inputs.jmx      ] Treat queries [{"object_name"=>"org.apache.activemq.artemis:broker=0.0.0.0,attribute=Version", "object_alias"=>"version"}]
[2020-07-29T13:57:40,044][DEBUG][logstash.inputs.jmx      ] Find all objects name org.apache.activemq.artemis:broker=0.0.0.0,attribute=Version
[2020-07-29T13:57:40,045][WARN ][logstash.inputs.jmx      ] No jmx object found for org.apache.activemq.artemis:broker=0.0.0.0,attribute=Version

I expected to return the version number here. Is the object name or configuration incorrect for logstash?


Solution

  • There is some issue with the object_name creation.

    Used the console to get the queue object name as below Artemis console configuration

    And include that in the jmxquery.config

    ...
    "queries" : [
      {
        "object_name" :  "org.apache.activemq.artemis:broker=\"0.0.0.0\",component=addresses,address=\"demo\"" ,
        "object_alias" : "version"
      } 
     ]
    ....
    

    Able to see the info shipped to kibana now.

    kibana ui

    Complete configuration, incase to limit the number of attributes to be pushed to Elastic, using attributes property.

    {
      "host" : "127.0.0.1",
      "port" : 1099,
      "url": "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi",
      "username" : "usern-name",
      "password" : "password-so-it-can-access-jmx-of-artemis",
       "alias" : "ActiveMQ",
      "queries" : [
    
      {
        "object_name" :  "org.apache.activemq.artemis:broker=\"broker-*\",component=addresses,address=*,subcomponent=queues,routing-type=\"anycast\",queue=*" ,
        "attributes" : ["Address","MessageCount","ConsumerCount","MessagesAcknowledged"],
         "object_alias" : "${address}"
      }    
     ]
    }