Search code examples
monitoringjmxzabbixactivemq-artemis

How to find/define JMX key for ActiveMQ Artemis monitoring


I'm trying to setup monitoring of ActiveMQ Artemis with Zabbix. My intention is to monitor the availability of Artemis and also monitor the size and number of messages accumulating in queues, and setup alerts.

I enabled JMX on Artemis as the documents in struct, and I built the JMX example. From what I can tell, this only involves adding the following lines to these two files in the broker:

management.xml

<connector connector-port="1099" connector-host="192.168.56.101" />

Opened the port: sudo ufw allow 1099

broker.xml

<jmx-management-enabled>true</jmx-management-enabled>

So I think JMX is enabled, although I haven't managed to confirm this.

In Zabbix I added the "host" (a system to monitor), but the next step is creating an "item" (a thing on the system). To do this I need a JMX key, something similar to 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.

So where can I find the keys for the available things to monitor on 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. 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.

Also, in the admin console for Artemis there is a JMX tab, which lists what I think is all the available things to monitor. For example, I have a queue called "test.queue". Under the JMX tab I find:

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(). 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]

{EDIT}

I'm looking at the JMX tab on the console. If I understand correctly, the key should have a format like this: 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"

And it has an attribute of: MessageCount

So I treid this, which doesn't work. I also tried replacing 0.0.0.0 with the IP address.

jmx[org.apache.activemq.artemis:broker="0.0.0.0",component=addresses,address="test.topic",subcomponent=queues,routing-type="multicast",queue="test.queue",MessageCount]


Solution

  • The default value for <jmx-management-enabled> is true so you don't need to explicitly configure that.

    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.

    The broker exposes lots of different MBeans for managing all parts of the broker. Here are the different "control" objects with their default MBean object naming pattern:

    • ActiveMQServerControl: <domain>:broker=<brokerName>
    • AddressControl: <domain>:broker=<brokerName>,component=addresses,address=<addressName>
    • 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>
    • ClusterConnectionControl: <domain>:broker=<brokerName>,component=cluster-connections,name=<clusterConnectionName>
    • AcceptorControl: <domain>:broker=<brokerName>,component=acceptors,name=<acceptorName>
    • BroadcastGroupControl: <domain>:broker=<brokerName>,component=broadcast-groups,name=<broadcastGroupName>
    • 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. You can see all the names of all the getters in the linked JavaDoc. 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().

    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:

    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.

    To be clear, the JMXExample you cited uses a handy helper method named getQueueObjectName to construct the MBean's object name.

    If you need to quickly get a broker up and running which supports remote JMX clients do the following:

    • Open the directory examples/features/standard/jmx in a terminal.
    • Run the example using mvn clean verify.
    • This will create a full broker instance in target/server0 which you can use as a template to configure your own. It includes modifications to broker.xml, management.xml, and artemis.profile (to set the java.rmi.server.hostname system property).

    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.