Prometheus and Grafana Integration with RabbitMQ Metrics
📖 Scenario: You are managing a RabbitMQ server that handles messages for your application. To keep track of its health and performance, you want to collect metrics and visualize them.Prometheus is a tool that collects metrics, and Grafana helps you create dashboards to see those metrics clearly.
🎯 Goal: Set up RabbitMQ metrics collection with Prometheus and create a simple Grafana dashboard to visualize the message rates.
📋 What You'll Learn
Enable the RabbitMQ Prometheus plugin
Configure RabbitMQ to expose metrics on port 15692
Set up Prometheus to scrape RabbitMQ metrics
Create a Grafana dashboard to display message rates
💡 Why This Matters
🌍 Real World
Monitoring RabbitMQ helps ensure your messaging system is healthy and responsive, preventing delays or failures in your application.
💼 Career
DevOps engineers often set up monitoring and alerting for message brokers like RabbitMQ to maintain system reliability.
Progress0 / 4 steps
1
Enable RabbitMQ Prometheus Plugin
Run the command rabbitmq-plugins enable rabbitmq_prometheus to enable the Prometheus plugin in RabbitMQ.
RabbitMQ
Hint
This command activates the plugin that allows RabbitMQ to expose metrics for Prometheus.
2
Configure RabbitMQ Metrics Port
Add the line listeners.tcp.prometheus = 15692 to the RabbitMQ configuration file /etc/rabbitmq/rabbitmq.conf to expose metrics on port 15692.
RabbitMQ
Hint
This setting tells RabbitMQ to open port 15692 for Prometheus to collect metrics.
3
Configure Prometheus to Scrape RabbitMQ Metrics
Add this job to the Prometheus configuration file prometheus.yml under scrape_configs: - job_name: 'rabbitmq', static_configs:, - targets: ['localhost:15692'].
RabbitMQ
Hint
This configuration tells Prometheus where to find RabbitMQ metrics.
4
Create Grafana Dashboard Panel for Message Rates
In Grafana, create a new dashboard and add a panel with the Prometheus query rate(rabbitmq_queue_messages_published_total[5m]) to show the message publish rate over the last 5 minutes.
RabbitMQ
Hint
This query calculates how many messages are published per second over the last 5 minutes.
Practice
(1/5)
1. What is the first step to enable monitoring of RabbitMQ metrics using Prometheus?
easy
A. Configure Prometheus scrape interval
B. Enable the RabbitMQ Prometheus plugin
C. Install Grafana dashboard
D. Restart the RabbitMQ server
Solution
Step 1: Enable RabbitMQ Prometheus plugin
This plugin exposes RabbitMQ metrics in a format Prometheus can scrape.
Step 2: Confirm plugin activation
Use rabbitmq-plugins enable rabbitmq_prometheus to activate it.
Final Answer:
Enable the RabbitMQ Prometheus plugin -> Option B
Quick Check:
Enable plugin = C [OK]
Hint: Start by enabling the Prometheus plugin in RabbitMQ [OK]
Common Mistakes:
Trying to configure Prometheus before enabling the plugin
Assuming Grafana setup is the first step
Restarting RabbitMQ without enabling the plugin
2. Which of the following is the correct Prometheus scrape configuration snippet to monitor RabbitMQ metrics?
easy
A. scrape_configs:
- job_name: 'rabbitmq'
static_configs:
- targets: ['localhost:15692']
B. scrape_configs:
- job_name: 'rabbitmq'
static_configs:
- targets: ['localhost:5672']
C. scrape_configs:
- job_name: 'rabbitmq'
static_configs:
- targets: ['localhost:15672']
D. scrape_configs:
- job_name: 'rabbitmq'
static_configs:
- targets: ['localhost:9090']
Solution
Step 1: Identify RabbitMQ Prometheus metrics port
The Prometheus plugin exposes metrics on port 15692 by default.
Step 2: Verify scrape target in Prometheus config
The target must be localhost:15692 to scrape RabbitMQ metrics correctly.
Final Answer:
scrape_configs with target localhost:15692 -> Option A
Quick Check:
Port 15692 for Prometheus metrics = A [OK]
Hint: Use port 15692 for RabbitMQ Prometheus metrics scrape [OK]
Common Mistakes:
Using RabbitMQ AMQP port 5672 instead of metrics port
Using RabbitMQ management port 15672 incorrectly
Using Prometheus default port 9090 as target
3. Given this Prometheus scrape config snippet, what will be the result when Prometheus scrapes RabbitMQ metrics?