提问者:小点点

ActiveMQ Artemis和Logstash JMX输入


我想使用logstash从JMX监控ActiveMQ Artemis并将数据发送到Elastic。

对于Artemis 2.13.0,

管理. xml

  • 注释掉

artemis. profile.cm d

  • 在JAVA_ARGS下添加了-Djava. rmi.server.hostname=localhost,因为Jsole/Logstash无法发现RMI JMX

设置ELK在我的本地windows 10机器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"
  } 
 ]
}

我能够使用localhost:1099与JConsole

但是,当我启动logstash时,JMX能够连接,但有一条消息说:“没有jmx对象”。

[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

我期望在这里返回版本号。logstash的对象名称或配置是否不正确?


共1个答案

匿名用户

创建object_name有一些问题。

并将其包含在jmxquery. config中

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

现在能够看到运往kibana的信息。

完整的配置,以限制要推送到Elastic的属性数量为例,使用属性属性。

{
  "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}"
  }    
 ]
}