0
0
RabbitMQdevops~10 mins

Prometheus and Grafana integration in RabbitMQ - Commands & Configuration

Choose your learning style9 modes available
Introduction
Prometheus collects and stores metrics from RabbitMQ to help monitor its health and performance. Grafana reads these metrics and shows them as easy-to-understand graphs and dashboards. This integration helps you see how RabbitMQ is working and catch problems early.
When you want to watch RabbitMQ message rates and queue sizes in real time.
When you need alerts if RabbitMQ is slow or has errors.
When you want to understand RabbitMQ usage patterns over time.
When you want to share RabbitMQ performance dashboards with your team.
When you want to troubleshoot RabbitMQ issues by looking at detailed metrics.
Config File - rabbitmq.conf
rabbitmq.conf
management.load_definitions = /etc/rabbitmq/definitions.json
listeners.tcp.default = 5672
management.listener.port = 15672
prometheus.tcp.port = 15692
prometheus.tcp.enabled = true

This RabbitMQ config enables the Prometheus plugin on port 15692 to expose metrics.

It also sets the management plugin port to 15672 for the web UI.

The load_definitions line is optional for loading predefined settings.

Commands
This command turns on the Prometheus plugin in RabbitMQ so it can expose metrics.
Terminal
rabbitmq-plugins enable rabbitmq_prometheus
Expected OutputExpected
The following plugins have been enabled: rabbitmq_prometheus
Restart RabbitMQ to apply the new configuration and enable the Prometheus metrics endpoint.
Terminal
systemctl restart rabbitmq-server
Expected OutputExpected
No output (command runs silently)
Check if RabbitMQ is exposing metrics on the Prometheus port by fetching the metrics data.
Terminal
curl http://localhost:15692/metrics
Expected OutputExpected
# HELP rabbitmq_queue_messages_ready Number of messages ready in the queue # TYPE rabbitmq_queue_messages_ready gauge rabbitmq_queue_messages_ready{queue="my-queue",vhost="/"} 0
Start Grafana in a Docker container to visualize the metrics from Prometheus.
Terminal
docker run -d -p 3000:3000 --name grafana grafana/grafana:9.5.2
Expected OutputExpected
Unable to find image 'grafana/grafana:9.5.2' locally 9.5.2: Pulling from grafana/grafana Digest: sha256:... Status: Downloaded newer image for grafana/grafana:9.5.2 <container_id>
-d - Run container in background
-p 3000:3000 - Map Grafana web UI to localhost port 3000
Check if Grafana is running and healthy by querying its health API.
Terminal
curl http://localhost:3000/api/health
Expected OutputExpected
{"database":"ok","version":"9.5.2","commit":"..."}
Key Concept

If you remember nothing else from this pattern, remember: enable the RabbitMQ Prometheus plugin to expose metrics, then use Grafana to visualize those metrics for easy monitoring.

Common Mistakes
Not enabling the rabbitmq_prometheus plugin before restarting RabbitMQ.
Without the plugin enabled, RabbitMQ won't expose metrics for Prometheus to scrape.
Run 'rabbitmq-plugins enable rabbitmq_prometheus' before restarting the RabbitMQ server.
Trying to access Prometheus metrics on the wrong port.
The metrics endpoint is on port 15692 by default, not the RabbitMQ main port 5672 or management port 15672.
Use 'curl http://localhost:15692/metrics' to check metrics.
Not starting Grafana or using an incorrect port to access it.
Grafana won't be available to view dashboards if the container is not running or port 3000 is blocked.
Run Grafana with 'docker run -d -p 3000:3000 grafana/grafana:9.5.2' and access it on http://localhost:3000.
Summary
Enable the RabbitMQ Prometheus plugin to expose metrics on port 15692.
Restart RabbitMQ to apply the plugin and configuration changes.
Verify metrics are available by fetching them with curl.
Run Grafana in Docker to visualize RabbitMQ metrics with dashboards.
Check Grafana health to ensure it is ready for use.