Bird
Raised Fist0
RabbitMQdevops~10 mins

Prometheus and Grafana integration in RabbitMQ - Commands & Configuration

Choose your learning style10 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.

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

  1. Step 1: Enable RabbitMQ Prometheus plugin

    This plugin exposes RabbitMQ metrics in a format Prometheus can scrape.
  2. Step 2: Confirm plugin activation

    Use rabbitmq-plugins enable rabbitmq_prometheus to activate it.
  3. Final Answer:

    Enable the RabbitMQ Prometheus plugin -> Option B
  4. 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

  1. Step 1: Identify RabbitMQ Prometheus metrics port

    The Prometheus plugin exposes metrics on port 15692 by default.
  2. Step 2: Verify scrape target in Prometheus config

    The target must be localhost:15692 to scrape RabbitMQ metrics correctly.
  3. Final Answer:

    scrape_configs with target localhost:15692 -> Option A
  4. 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?
scrape_configs:
  - job_name: 'rabbitmq'
    static_configs:
      - targets: ['rabbitmq-server:15692']
medium
A. Prometheus will fail due to wrong port
B. Prometheus will ignore this job
C. Prometheus will collect metrics but with errors
D. Prometheus will collect RabbitMQ metrics successfully

Solution

  1. Step 1: Check target hostname and port

    The target rabbitmq-server:15692 is valid if DNS resolves and port 15692 is open.
  2. Step 2: Confirm Prometheus plugin exposes metrics on port 15692

    This matches the default port for RabbitMQ Prometheus plugin metrics.
  3. Final Answer:

    Prometheus will collect RabbitMQ metrics successfully -> Option D
  4. Quick Check:

    Correct hostname and port = B [OK]
Hint: Correct hostname and port means successful scrape [OK]
Common Mistakes:
  • Assuming port 15692 is incorrect
  • Ignoring hostname resolution issues
  • Confusing management port with metrics port
4. You configured Prometheus to scrape RabbitMQ metrics but see no data in Grafana dashboards. What is the most likely cause?
medium
A. Prometheus scrape interval is too long
B. Grafana is not installed
C. RabbitMQ Prometheus plugin is not enabled
D. RabbitMQ server is down

Solution

  1. Step 1: Check if RabbitMQ Prometheus plugin is enabled

    If the plugin is disabled, no metrics are exposed for Prometheus to scrape.
  2. Step 2: Confirm plugin activation with rabbitmq-plugins list

    This command shows enabled plugins; absence of rabbitmq_prometheus means no metrics.
  3. Final Answer:

    RabbitMQ Prometheus plugin is not enabled -> Option C
  4. Quick Check:

    Plugin disabled = no metrics = A [OK]
Hint: Check plugin enabled before blaming Grafana or Prometheus [OK]
Common Mistakes:
  • Assuming Grafana installation causes no data
  • Blaming scrape interval without checking metrics exposure
  • Ignoring RabbitMQ server status
5. You want to create a Grafana dashboard to monitor RabbitMQ queue length over time. Which data source and query setup is correct?
hard
A. Use Prometheus data source; query rabbitmq_queue_messages_ready
B. Use RabbitMQ data source; query queue_length
C. Use Prometheus data source; query rabbitmq_queue_consumers
D. Use Grafana Loki data source; query queue_length_logs

Solution

  1. Step 1: Identify correct data source for RabbitMQ metrics

    Prometheus is used to collect and store RabbitMQ metrics exposed by the plugin.
  2. Step 2: Select the metric for queue length

    rabbitmq_queue_messages_ready represents the number of messages ready in queues.
  3. Final Answer:

    Use Prometheus data source; query rabbitmq_queue_messages_ready -> Option A
  4. Quick Check:

    Prometheus + rabbitmq_queue_messages_ready = D [OK]
Hint: Use Prometheus and metric rabbitmq_queue_messages_ready for queue length [OK]
Common Mistakes:
  • Using RabbitMQ data source which is not standard for Grafana
  • Querying consumers count instead of queue length
  • Using Loki which is for logs, not metrics
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard