ActiveMQ Artemis 和 Logstash JMX 输入

huangapple go评论79阅读模式
英文:

ActiveMQ Artemis and Logstash JMX input

问题

我想要监视 ActiveMQ Artemis,并使用 Logstash 通过 JMX 将数据传输到 Elastic。

对于 Artemis 2.13.0,

management.xml:

  • 注释掉了 <authorisation> 标签
  • 添加了 <connector connector-port="1099">

artemis.profile.cmd:

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

在我的本地 Windows 10 机器上设置 ELK

local-jmx.config

input {
  jmx {
    path => "/path/to/config/"  // 这里有一个文件 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 能够连接,但会显示消息 "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

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

英文:

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 &lt;authorisation&gt; tag
  • added &lt;connector connector-port=&quot;1099&quot;&gt;

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 =&gt; &quot;/path/to/config/&quot;  //This has a file jmxquery.config
    polling_frequency =&gt; 60
    nb_thread =&gt; 5
    type =&gt; &quot;jmx&quot;
  }
}
output {
    elasticsearch {
        hosts =&gt; [ &quot;localhost:9200&quot; ]
    }
}

jmxquery.config :

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

I am able to use localhost:1099 with JConsole

ActiveMQ Artemis 和 Logstash JMX 输入

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 {&quot;host&quot;=&gt;&quot;127.0.0.1&quot;, &quot;port&quot;=&gt;1099, &quot;url&quot;=&gt;&quot;service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi&quot;, &quot;username&quot;=&gt;&quot;guest&quot;, &quot;password&quot;=&gt;&quot;guest&quot;, &quot;alias&quot;=&gt;&quot;ActiveMQ&quot;, &quot;queries&quot;=&gt;[{&quot;object_name&quot;=&gt;&quot;org.apache.activemq.artemis:broker=0.0.0.0,attribute=Version&quot;, &quot;object_alias&quot;=&gt;&quot;version&quot;}]} 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 [{&quot;object_name&quot;=&gt;&quot;org.apache.activemq.artemis:broker=0.0.0.0,attribute=Version&quot;, &quot;object_alias&quot;=&gt;&quot;version&quot;}]
[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?

答案1

得分: 0

对象名称创建存在一些问题。

使用控制台获取队列对象名称如下
ActiveMQ Artemis 和 Logstash JMX 输入

并将其包含在jmxquery.config中

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

现在可以看到信息已发送到Kibana。

ActiveMQ Artemis 和 Logstash JMX 输入

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

{
  "host" : "127.0.0.1",
  "port" : 1099,
  "url": "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi",
  "username" : "用户名",
  "password" : "密码-以便访问artemis的jmx",
   "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}"
  }    
 ]
}
英文:

There is some issue with the object_name creation.

Used the console to get the queue object name as below
ActiveMQ Artemis 和 Logstash JMX 输入

And include that in the jmxquery.config

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

Able to see the info shipped to kibana now.

ActiveMQ Artemis 和 Logstash JMX 输入

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

{
  &quot;host&quot; : &quot;127.0.0.1&quot;,
  &quot;port&quot; : 1099,
  &quot;url&quot;: &quot;service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi&quot;,
  &quot;username&quot; : &quot;usern-name&quot;,
  &quot;password&quot; : &quot;password-so-it-can-access-jmx-of-artemis&quot;,
   &quot;alias&quot; : &quot;ActiveMQ&quot;,
  &quot;queries&quot; : [

  {
    &quot;object_name&quot; :  &quot;org.apache.activemq.artemis:broker=\&quot;broker-*\&quot;,component=addresses,address=*,subcomponent=queues,routing-type=\&quot;anycast\&quot;,queue=*&quot; ,
	&quot;attributes&quot; : [&quot;Address&quot;,&quot;MessageCount&quot;,&quot;ConsumerCount&quot;,&quot;MessagesAcknowledged&quot;],
     &quot;object_alias&quot; : &quot;${address}&quot;
  }    
 ]
}

huangapple
  • 本文由 发表于 2020年7月30日 05:06:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/63162424.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定