[英]How to find/define JMX key for ActiveMQ Artemis monitoring
I'm trying to setup monitoring of ActiveMQ Artemis with Zabbix.我正在尝试使用 Zabbix 设置对 ActiveMQ Artemis 的监控。 My intention is to monitor the availability of Artemis and also monitor the size and number of messages accumulating in queues, and setup alerts.
我的目的是监控 Artemis 的可用性,并监控队列中累积的消息的大小和数量,并设置警报。
I enabled JMX on Artemis as the documents in struct, and I built the JMX example.我在 Artemis 上启用了 JMX 作为结构中的文档,并构建了 JMX 示例。 From what I can tell, this only involves adding the following lines to these two files in the broker:
据我所知,这只涉及将以下行添加到代理中的这两个文件中:
management.xml管理.xml
<connector connector-port="1099" connector-host="192.168.56.101" />
Opened the port: sudo ufw allow 1099开启端口:sudo ufw allow 1099
broker.xml经纪人.xml
<jmx-management-enabled>true</jmx-management-enabled>
So I think JMX is enabled, although I haven't managed to confirm this.所以我认为 JMX 已启用,尽管我还没有设法确认这一点。
In Zabbix I added the "host" (a system to monitor), but the next step is creating an "item" (a thing on the system).在 Zabbix 中,我添加了“主机”(一个要监控的系统),但下一步是创建一个“项目”(系统上的一个东西)。 To do this I need a JMX key, something similar to jmx["java.lang:type=Memory","HeapMemoryUsage.used"].
为此,我需要一个 JMX 密钥,类似于 jmx["java.lang:type=Memory","HeapMemoryUsage.used"]。 (I tried this one but I don't get any data back) This defines the MBean to call.
(我试过这个,但没有得到任何数据)这定义了要调用的 MBean。
So where can I find the keys for the available things to monitor on Artemis?那么我在哪里可以找到用于在 Artemis 上监控的可用内容的密钥? Or have I screwed something up here and am not looking for the right thing?
还是我在这里搞砸了,而不是在寻找正确的东西?
In the example there is a JMWExample.java program.在示例中有一个 JMWExample.java 程序。 It connects to Artemis, publishes a message, uses JMX to count the messages, then removes the message -- but I don't see any keys to MBeans.
它连接到 Artemis,发布一条消息,使用 JMX 对消息进行计数,然后删除消息——但我没有看到任何指向 MBean 的键。
Also, in the admin console for Artemis there is a JMX tab, which lists what I think is all the available things to monitor.此外,在 Artemis 的管理控制台中有一个 JMX 选项卡,其中列出了我认为是所有可用的监控内容。 For example, I have a queue called "test.queue".
例如,我有一个名为“test.queue”的队列。 Under the JMX tab I find:
在 JMX 选项卡下,我发现:
org.apache.activemq.artemis:broker="0.0.0.0",component=addresses,address="test.topic",subcomponent=queues,routing-type="multicast",queue="test.queue"
And there are numerous methods listed, including countMessages().并且列出了许多方法,包括 countMessages()。 Have I answered my own question here?
我在这里回答了我自己的问题吗? Is this what I'm looking for?
这就是我要找的吗?
If so, how does it fit into this key format, jmx[object_name,attribute_name]如果是这样,它如何适合这种键格式,jmx[object_name,attribute_name]
{EDIT} {编辑}
I'm looking at the JMX tab on the console.我正在查看控制台上的 JMX 选项卡。 If I understand correctly, the key should have a format like this: jmx[object_name,attribute_name]
如果我理解正确的话,密钥的格式应该是这样的:jmx[object_name,attribute_name]
So I see the the object name under the JMX tab for one of my test queues is: org.apache.activemq.artemis:broker="0.0.0.0",component=addresses,address="test.topic",subcomponent=queues,routing-type="multicast",queue="test.queue"所以我看到我的一个测试队列的 JMX 选项卡下的 object 名称是:org.apache.activemq.artemis:broker="0.0.0.0",component=addresses,address="test.topic",subcomponent=queues ,routing-type="multicast",queue="test.queue"
And it has an attribute of: MessageCount它有一个属性:MessageCount
So I treid this, which doesn't work.所以我尝试了这个,这是行不通的。 I also tried replacing 0.0.0.0 with the IP address.
我还尝试用 IP 地址替换 0.0.0.0。
jmx[org.apache.activemq.artemis:broker="0.0.0.0",component=addresses,address="test.topic",subcomponent=queues,routing-type="multicast",queue="test.queue",MessageCount] jmx[org.apache.activemq.artemis:broker="0.0.0.0",component=addresses,address="test.topic",subcomponent=queues,routing-type="multicast",queue="test.queue", MessageCount]
The default value for <jmx-management-enabled>
is true
so you don't need to explicitly configure that. <jmx-management-enabled>
的默认值为true
,因此您无需显式配置它。
You can confirm that JMX is enabled by connecting to the broker using a tool like JConsole or JVisualVM which ship with the JVM. Ideally you would do this locally to avoid any.network configuration issues.您可以通过使用 JVM 附带的 JConsole 或 JVisualVM 等工具连接到代理来确认 JMX 已启用。理想情况下,您可以在本地执行此操作以避免任何网络配置问题。
The broker exposes lots of different MBeans for managing all parts of the broker.代理公开了许多不同的 MBean 来管理代理的所有部分。 Here are the different "control" objects with their default MBean object naming pattern :
以下是具有默认 MBean object 命名模式的不同“控制”对象:
ActiveMQServerControl
: <domain>:broker=<brokerName>
ActiveMQServerControl
: <domain>:broker=<brokerName>
AddressControl
: <domain>:broker=<brokerName>,component=addresses,address=<addressName>
<domain>:broker=<brokerName>,component=addresses,address=<addressName>
AddressControl
QueueControl
: <domain>:broker=<brokerName>,component=addresses,address=<addressName>,subcomponent=queues,routing-type=<routingType>,queue=<queueName>
QueueControl
: <domain>:broker=<brokerName>,component=addresses,address=<addressName>,subcomponent=queues,routing-type=<routingType>,queue=<queueName>
DivertControl
: <domain>:broker=<brokerName>,component=addresses,address=<addressName>,subcomponent=diverts,divert=<divertName>
DivertControl
: <domain>:broker=<brokerName>,component=addresses,address=<addressName>,subcomponent=diverts,divert=<divertName>
ClusterConnectionControl
: <domain>:broker=<brokerName>,component=cluster-connections,name=<clusterConnectionName>
ClusterConnectionControl
: <domain>:broker=<brokerName>,component=cluster-connections,name=<clusterConnectionName>
AcceptorControl
: <domain>:broker=<brokerName>,component=acceptors,name=<acceptorName>
AcceptorControl
: <domain>:broker=<brokerName>,component=acceptors,name=<acceptorName>
BroadcastGroupControl
: <domain>:broker=<brokerName>,component=broadcast-groups,name=<broadcastGroupName>
BroadcastGroupControl
: <domain>:broker=<brokerName>,component=broadcast-groups,name=<broadcastGroupName>
BridgeControl
: <domain>:broker=<brokerName>,component=bridges,name=<bridgeName>
BridgeControl
: <domain>:broker=<brokerName>,component=bridges,name=<bridgeName>
The "key" that you use will depend on the name of the attribute from the control that you want to inspect.您使用的“键”将取决于您要检查的控件的属性名称。 That name will correspond to the "getter" of the attribute.
该名称将对应于属性的“getter”。 You can see all the names of all the getters in the linked JavaDoc.
您可以在链接的 JavaDoc 中看到所有 getter 的所有名称。 For example, if you want to get the number of messages from a queue you'd use the key
MessageCount
since the getter is named getMessageCount()
.例如,如果您想从队列中获取消息的数量,您将使用键
MessageCount
因为 getter 名为getMessageCount()
。
The domain by default is org.apache.activemq.artemis
and the default broker name is localhost
so if you didn't explicitly configure either of these and you wanted to get the message count of the anycast queue "myQueue" on the address "myAddress" you would use something like this:默认域是
org.apache.activemq.artemis
并且默认代理名称是localhost
所以如果你没有明确配置其中任何一个并且你想获取地址“myAddress”上的任播队列“myQueue”的消息计数“你会使用这样的东西:
jmx["org.apache.activemq.artemis:broker=\"localhost\",component=addresses,address=\"myAddress\",subcomponent=queues,routing-type=\"anycast\",queue=\"myQueue\"",MessageCount]
This formatting is based on this Zabbix block post which is also discussed on this Zabbix forum thread .此格式基于此 Zabbix 块帖子,该帖子也在此 Zabbix 论坛线程中进行了讨论。
To be clear, the JMXExample
you cited uses a handy helper method named getQueueObjectName
to construct the MBean's object name.明确地说, 您引用的
JMXExample
使用一个名为getQueueObjectName
的方便的帮助器方法来构造 MBean 的 object 名称。
If you need to quickly get a broker up and running which supports remote JMX clients do the following:如果您需要快速启动并运行支持远程 JMX 客户端的代理,请执行以下操作:
examples/features/standard/jmx
in a terminal.examples/features/standard/jmx
。mvn clean verify
.mvn clean verify
运行示例。target/server0
which you can use as a template to configure your own.target/server0
中创建一个完整的代理实例,您可以将其用作配置您自己的模板。 It includes modifications to broker.xml
, management.xml
, and artemis.profile
(to set the java.rmi.server.hostname
system property).broker.xml
、 management.xml
和artemis.profile
的修改(以设置java.rmi.server.hostname
系统属性)。 If you start this broker instance manually you can connect to it with JConsole or JVisualVM using service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
.如果您手动启动此代理实例,则可以使用
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
通过 JConsole 或 JVisualVM 连接到它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.