Tracing or Logging RabbitMQ

Messaging queues like RabbitMQ are widely used. For example it is a key component in an OpenStack deployment.

Sometimes you need to peek into the queue and see what is happening and I thought I would write a quick post on one way to do that.

Turn on the firehose

Rabbit has an option to turn on “tracing” so that you can see every message that is coming through the queue.

RabbitMQ has a “firehose” feature, where the administrator can enable (on a per-node, per-vhost basis) an exchange to which publish- and delivery-notifications should be CCed. - RabbitMQ

If you have a default install and just want the “/” vhost, you can simply turn on tracing.

Now you need to read that queue.

Reading messages on the firehose queue

You will need a script to read the queue.

I just grabbed one off of github, but it would be straight forward to write your own.

This particular python script uses the pika library.

Now you can turn on the firehose. I’m going to redirect to a file because there are a lot of messages.

Once you’ve got the messages you want, turn off tracing.

You might need to empty out the firehost queue.
[{"document_url": "https://serverascode.com/2016/12/17/tracing-logging-rabbitmq.html", "unformatted_src": "/img/rabbitmq.jpg", "src": "https://serverascode.com/img/rabbitmq.jpg", "formatted_filename": "rabbitmq", "alt_text": "painting"}, null]