Bootstrap FreeKB - RabbitMQ - Count the number of messages in a queue using the REST API
RabbitMQ - Count the number of messages in a queue using the REST API

Updated:   |  RabbitMQ articles

This assumes you have created a RabbitMQ user with the administrator tag.

Refer to the RabbitMQ REST API documentation.

The curl command with the --user option can be used to make an API connection to RabbitMQ. In this example, John Doe will make a connection to the RabbitMQ server listening on port 15671.

curl
--request GET
--user john.doe:itsasecret
--url https://hostname:15671/api/queues

 

Or, you can specify a single queue.

curl
--request GET
--user john.doe:itsasecret
--url https://hostname:15671/api/queues/vhost001/queue001

 

For the / vhost, use %2F.

curl
--request GET
--user john.doe:itsasecret
--url https://hostname:15671/api/queues/%2F/queue001

 

Something like this should be returned for each queue. Notice this output includes a number of "messages" keys.

{"messages_details":{"rate":0.0} 
"messages":0 
"messages_unacknowledged_details":{"rate":0.0} 
"messages_unacknowledged":0 
"messages_ready_details":{"rate":0.0} 
"messages_ready":0 
"reductions_details":{"rate":0.0} 
"reductions":2789586 
"node":"rabbit@server001" 
"arguments":{} 
"exclusive":false 
"auto_delete":false 
"durable":true 
"vhost":"/" 
"name":"queue001" 
"message_bytes_paged_out":0 
"messages_paged_out":0 
"backing_queue_status":{"mode":"default" 
"q1":0 
"q2":0 
"delta":["delta" 
"undefined" 
0 
0 
"undefined"] 
"q3":0 
"q4":0 
"len":0 
"target_ram_count":0 
"next_seq_id":0 
"avg_ingress_rate":0.0 
"avg_egress_rate":0.0 
"avg_ack_ingress_rate":0.0 
"avg_ack_egress_rate":0.0 
"mirror_seen":0 
"mirror_senders":0} 
"head_message_timestamp":null 
"message_bytes_persistent":0 
"message_bytes_ram":0 
"message_bytes_unacknowledged":0 
"message_bytes_ready":0 
"message_bytes":0 
"messages_persistent":0 
"messages_unacknowledged_ram":0 
"messages_ready_ram":0 
"messages_ram":0 
"garbage_collection":{"minor_gcs":1817 
"fullsweep_after":65535 
"min_heap_size":233 
"min_bin_vheap_size":46422} 
"state":"running" 
"recoverable_slaves":["rabbit@server001"] 
"synchronised_slave_nodes":["rabbit@server001"] 
"slave_nodes":["rabbit@server001"] 
"memory":68224 
"consumer_utilisation":null 
"consumers":0 
"exclusive_consumer_tag":null 
"policy":"ha_mirror_two"}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter d6d06d in the box below so that we can be sure you are a human.