Monitoring RabbitMQ

A message broker is a very important component in a software architecture.

In a company, it’s the element that deal with the communications between many applications, if not all; so the monitoring of the performance and the healty of this system is very important.

Fortunately RabbitMQ offer a lot of api that we can call to check the status of the server, like the allocated memory or the number of the message ready on a specific queue.

For example with this url we can retrieve a lot of useful informations about the status of the server:


http://hostname:15672/api/overview

This is a subset of the informations retrieved:

{
"management_version": "3.7.14",
"rates_mode": "basic",
.....
"message_stats": {
"ack": 730614,
"ack_details": {
"rate": 0.0
},
"confirm": 0,
"confirm_details": {
"rate": 0.0
},
"deliver": 731588,
"deliver_details": {
"rate": 0.0
},
"deliver_get": 741487,
"deliver_get_details": {
"rate": 0.0
},
"deliver_no_ack": 9899,
"deliver_no_ack_details": {
"rate": 0.0
},
"disk_reads": 0,
"disk_reads_details": {
"rate": 0.0
},
"disk_writes": 0,
"disk_writes_details": {
"rate": 0.0
},
"get": 0,
"get_details": {
"rate": 0.0
},
"get_no_ack": 0,
"get_no_ack_details": {
"rate": 0.0
},
"publish": 760106,
"publish_details": {
"rate": 0.0
},
"redeliver": 874,
"redeliver_details": {
"rate": 0.0
},
"return_unroutable": 0,
"return_unroutable_details": {
"rate": 0.0
}
},
"churn_rates": {
"channel_closed": 23054,
"channel_closed_details": {
"rate": 0.0
},
"channel_created": 23292,
"channel_created_details": {
"rate": 0.0
},
"connection_closed": 40271,
"connection_closed_details": {
"rate": 0.0
},
"connection_created": 23292,
"connection_created_details": {
"rate": 0.0
},
"queue_created": 3156,
"queue_created_details": {
"rate": 0.0
},
"queue_declared": 6639,
"queue_declared_details": {
"rate": 0.0
},
"queue_deleted": 2628,
"queue_deleted_details": {
"rate": 0.0
}
},
"queue_totals": {
"messages": 11793,
"messages_details": {
"rate": 0.0
},
"messages_ready": 11693,
"messages_ready_details": {
"rate": 0.0
},
"messages_unacknowledged": 100,
"messages_unacknowledged_details": {
"rate": 0.0
}
},
"object_totals": {
"channels": 238,
"connections": 238,
"consumers": 259,
"exchanges": 34,
"queues": 529
}
}

As you can see we can have access to informations about the version of the server, the configurations, the usage of the queues and a summary about the totals objects configured on the server; this is only a subset of all informations returned by the api.

The result of these api is in JSON format, so we can use a deserializer to have the datas in an object.

We can access specific informations as well, for example we can retrieve details about the memory usage of the server:


http://hostname:15672/api/nodes/rabbit@hostname/memory

This is the result of the api call:

{
"memory": {
"connection_readers": 3739144,
"connection_writers": 182456,
"connection_channels": 661012,
"connection_other": 10032932,
"queue_procs": 4718948,
"queue_slave_procs": 0,
"plugins": 25763856,
"other_proc": 25659816,
"metrics": 1564868,
"mgmt_db": 23254048,
"mnesia": 989712,
"other_ets": 3653328,
"binary": 9251872,
"msg_index": 119296,
"code": 27690369,
"atom": 1172689,
"other_system": 11682790,
"allocated_unused": 44570320,
"reserved_unallocated": 0,
"strategy": "rss",
"total": {
"erlang": 150137136,
"rss": 194707456,
"allocated": 194707456
}
}
}

So with the property memory.total.allocated we can retrieve the total memory used by the server.

Another metric that we could monitor is the number of messages ready on queue.

In case of real time communications this could be a significant information; for example it could means problems with the consumers of these message and consequently problems with informations that should be delivered in real time.

If we want to retrieve the messages in a queue we can use this api:


http://hostname:15672/api/queues/queue1

And the result is:

{
"consumer_details": [
{
"arguments": {},
"channel_details": {
"connection_name": "connection name",
"name": "name",
"node": "rabbit@hostname",
"number": 1,
"peer_host": "ip address",
"peer_port": 59645,
"user": "username"
},
"ack_required": true,
"consumer_tag": "amq.ctag-5uIlJoVJhfIbg0Vi3twEmQ",
"exclusive": false,
"prefetch_count": 0,
"queue": {
"name": "queue1",
"vhost": ""
}
}
],
"arguments": {},
"auto_delete": false,
"backing_queue_status": {
"avg_ack_egress_rate": 0.17747955505781565,
"avg_ack_ingress_rate": 0.17747955505781565,
"avg_egress_rate": 0.17747955505781565,
"avg_ingress_rate": 0.17747955505781565,
"delta": [
"delta",
"undefined",
0,
0,
"undefined"
],
"len": 0,
"mode": "default",
"next_seq_id": 17713,
"q1": 0,
"q2": 0,
"q3": 0,
"q4": 0,
"target_ram_count": "infinity"
},
"consumer_utilisation": 1.0,
"consumers": 1,
"deliveries": [],
"durable": false,
"effective_policy_definition": [],
"exclusive": false,
"exclusive_consumer_tag": null,
"garbage_collection": {
"fullsweep_after": 65535,
"max_heap_size": 0,
"min_bin_vheap_size": 46422,
"min_heap_size": 233,
"minor_gcs": 1100
},
"head_message_timestamp": null,
"incoming": [],
"memory": 42780,
"message_bytes": 0,
"message_bytes_paged_out": 0,
"message_bytes_persistent": 0,
"message_bytes_ram": 0,
"message_bytes_ready": 0,
"message_bytes_unacknowledged": 0,
"message_stats": {
"ack": 17713,
"ack_details": {
"rate": 0.0
},
"deliver": 17713,
"deliver_details": {
"rate": 0.0
},
"deliver_get": 17713,
"deliver_get_details": {
"rate": 0.0
},
"deliver_no_ack": 0,
"deliver_no_ack_details": {
"rate": 0.0
},
"get": 0,
"get_details": {
"rate": 0.0
},
"get_no_ack": 0,
"get_no_ack_details": {
"rate": 0.0
},
"publish": 17350,
"publish_details": {
"rate": 0.0
},
"redeliver": 0,
"redeliver_details": {
"rate": 0.0
}
},
"messages": 0,
"messages_details": {
"rate": 0.0
},
"messages_paged_out": 0,
"messages_persistent": 0,
"messages_ram": 0,
"messages_ready": 0,
"messages_ready_details": {
"rate": 0.0
},
"messages_ready_ram": 0,
"messages_unacknowledged": 0,
"messages_unacknowledged_details": {
"rate": 0.0
},
"messages_unacknowledged_ram": 0,
"name": "queue1",
"node": "rabbit@hostname",
"operator_policy": null,
"policy": null,
"recoverable_slaves": null,
"reductions": 25868248,
"reductions_details": {
"rate": 308.2
},
"state": "running",
"vhost": ""
}

With the messages property we can retrieve the number of messages not consumed yet and so verify potential anomalies in the consumers.

You can find more informations about RabbitMQ monitoring at the official documentation.

 

One thought on “Monitoring RabbitMQ

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: