Chapter 33. Monitoring Messaging Statistics
When statistics collection is enabled for a messaging server in the messaging-activemq
subsystem, you can view runtime statistics for resources on the messaging server.
33.1. Enabling Messaging Statistics
Because it can negatively impact performance, statistics collection for the messaging-activemq
subsystem is not enabled by default. You do not need to enable queue statistics to obtain basic information, such as as number of messages on a queue or the number of messages added to a queue. Those statistics are available using queue attributes without requiring that you set statistics-enabled
to true
.
You can enable additional statistics collection using the management CLI or the management console.
Enable Messaging Statistics Using the Management CLI
The following management CLI command enables the collection of statistics for the default
messaging server.
/subsystem=messaging-activemq/server=default:write-attribute(name=statistics-enabled,value=true)
Pooled connection factory statistics are enabled separately from the other messaging server statistics. Use the following command to enable statistics for a pooled connection factory.
/subsystem=messaging-activemq/server=default/pooled-connection-factory=activemq-ra:write-attribute(name=statistics-enabled,value=true)
Reload the server for the changes to take effect.
Enable Messaging Statistics Using the Management Console
Use the following steps to enable statistics collection for a messaging server using the management console.
- Navigate to Configuration → Subsystems → Messaging (ActiveMQ) → Server.
- Select the server and click View.
- Click Edit under the Statistics tab.
- Set the Statistics Enabled field to ON and click Save.
Pooled connection factory statistics are enabled separately from the other messaging server statistics. Use the following steps to enable statistics collection for a pooled connection factory.
- Navigate to Configuration → Subsystems → Messaging (ActiveMQ) → Server.
- Select the server, select Connections, and click View.
- Select the Pooled Connection Factory tab.
- Select the pooled connection factory and click Edit under the Attributes tab.
- Set the Statistics Enabled field to ON and click Save.
- Reload the server for the changes to take effect.
33.2. Viewing Messaging Statistics
You can view runtime statistics for a messaging server using the management CLI or management console.
View Messaging Statistics Using the Management CLI
You can view messaging statistics using the following management CLI commands. Be sure to include the include-runtime=true
argument as statistics are runtime information.
View statistics for a queue.
/subsystem=messaging-activemq/server=default/jms-queue=DLQ:read-resource(include-runtime=true) { "outcome" => "success", "result" => { "consumer-count" => 0, "dead-letter-address" => "jms.queue.DLQ", "delivering-count" => 0, "durable" => true, ... } }
View statistics for a topic.
/subsystem=messaging-activemq/server=default/jms-topic=testTopic:read-resource(include-runtime=true) { "outcome" => "success", "result" => { "delivering-count" => 0, "durable-message-count" => 0, "durable-subscription-count" => 0, ... } }
View statistics for a pooled connection factory.
/subsystem=messaging-activemq/server=default/pooled-connection-factory=activemq-ra/statistics=pool:read-resource(include-runtime=true) { "outcome" => "success", "result" => { "ActiveCount" => 1, "AvailableCount" => 20, "AverageBlockingTime" => 0L, "AverageCreationTime" => 13L, "AverageGetTime" => 14L, ... } }
NotePooled connection factory statistics are enabled separately from the other messaging server statistics. See Enabling Messaging Statistics for instructions.
View Messaging Statistics Using the Management Console
To view messaging statistics from the management console, navigate to the Messaging (ActiveMQ) subsystem from the Runtime tab, and select the server. Select a destination to view its statistics.
The Prepared Transactions page is where you can view, commit, and roll back prepared transactions. See Managing Messaging Journal Prepared Transactions for more information.
See Messaging Statistics for a detailed list of all available statistics.
33.3. Configuring Message Counters
You can configure the following message counter attributes for a messaging server.
-
message-counter-max-day-history
: The number of days the message counter history is kept. -
message-counter-sample-period
: How often, in milliseconds, the queue is sampled.
The management CLI command to configure these options uses the following syntax. Be sure to replace STATISTICS_NAME
and STATISTICS_VALUE
with the statistic name and value you want to configure.
/subsystem=messaging-activemq/server=default::write-attribute(name=STATISTICS_NAME,value=STATISTICS_VALUE)
For example, use the following commands to set the message-counter-max-day-history
to five days and the message-counter-sample-period
to two seconds.
/subsystem=messaging-activemq/server=default:write-attribute(name=message-counter-max-day-history,value=5) /subsystem=messaging-activemq/server=default:write-attribute(name=message-counter-sample-period,value=2000)
33.4. Viewing the Message Counter and History for a Queue
You can view the message counter and message counter history for a queue using the following management CLI operations.
-
list-message-counter-as-json
-
list-message-counter-as-html
-
list-message-counter-history-as-json
-
list-message-counter-history-as-html
The management CLI command to use display these values uses the following syntax. Be sure to replace QUEUE_NAME
and OPERATION_NAME
with the queue name and operation you want to use.
/subsystem=messaging-activemq/server=default/jms-queue=QUEUE_NAME:OPERATION_NAME
For example, use the following command to view the message counter for the TestQueue
queue in JSON format.
/subsystem=messaging-activemq/server=default/jms-queue=TestQueue:list-message-counter-as-json { "outcome" => "success", "result" => "{\"destinationName\":\"TestQueue\",\"destinationSubscription\":null,\"destinationDurable\":true,\"count\":0,\"countDelta\":0,\"messageCount\":0,\"messageCountDelta\":0,\"lastAddTimestamp\":\"12/31/69 7:00:00 PM\",\"updateTimestamp\":\"2/20/18 2:24:05 PM\"}" }
33.5. Reset the Message Counter for a Queue
You can reset the message counter for a queue using the reset-message-counter
management CLI operation.
/subsystem=messaging-activemq/server=default/jms-queue=TestQueue:reset-message-counter { "outcome" => "success", "result" => undefined }