英文:
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
<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
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?
答案1
得分: 0
对象名称创建存在一些问题。
并将其包含在jmxquery.config中
...
"queries" : [
{
"object_name" : "org.apache.activemq.artemis:broker=\"0.0.0.0\",component=addresses,address=\"demo\"" ,
"object_alias" : "version"
}
]
....
现在可以看到信息已发送到Kibana。
完整配置,以限制要推送到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
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.
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}"
}
]
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论