CubeAPM
CubeAPM CubeAPM

How to Expose RabbitMQ Metrics to Prometheus (Step-by-Step)

How to Expose RabbitMQ Metrics to Prometheus (Step-by-Step)

Table of Contents

RabbitMQ ships with a built-in Prometheus plugin called rabbitmq_prometheus, available since RabbitMQ 3.8.0. Enabling it takes a single command, and within minutes Prometheus can scrape broker, queue, connection, and runtime metrics from a dedicated HTTP endpoint on port 15692. This guide walks you through each step, explains the key metrics to watch, and shows you how to visualise everything in Grafana.

If you are still using the Management Plugin API (port 15672) as your primary metrics source, this guide will also show you why the Prometheus plugin is the recommended replacement for production systems.

💡 Key Takeaways
  • RabbitMQ 3.8+ includes the rabbitmq_prometheus plugin. One command enables it.
  • Metrics are served on port 15692 at the /metrics endpoint in Prometheus text format.
  • Default metrics are aggregated across all queues. Use /metrics/detailed for per-object data.
  • Prometheus scrapes each node individually, making the setup resilient to partial cluster failures.
  • RabbitMQ maintains pre-built Grafana dashboards (Dashboard ID 10991) ready to import.
  • In Kubernetes, the RabbitMQ Cluster Operator enables the plugin automatically.
  • The Management Plugin (port 15672) is not recommended for production-grade metric collection.

Prerequisites

Before you start, make sure you have the following:

  • RabbitMQ 3.8.0 or later installed and running
  • Prometheus installed (v2.x recommended)
  • Access to the RabbitMQ host to run rabbitmq-plugins commands (or Docker / Kubernetes access)
  • Optional: Grafana for dashboard visualisation

Step 1: Enable the rabbitmq_prometheus Plugin

The simplest way to expose RabbitMQ metrics to Prometheus is to enable the built-in plugin. Run the following command on every RabbitMQ node:

rabbitmq-plugins enable rabbitmq_prometheus

If you are running RabbitMQ inside Docker, use:

docker exec -it <rabbitmq_container_name> rabbitmq-plugins enable rabbitmq_prometheus

No restart is required. The plugin activates immediately. Verify it is running with:

rabbitmq-plugins list | grep prometheus
# Expected output:
[E*] rabbitmq_prometheus              3.x.x

Verify the Metrics Endpoint

The plugin exposes metrics on port 15692. Hit the endpoint with curl to confirm it is responding:

curl http://localhost:15692/metrics

You should see output in Prometheus text format, for example lines like rabbitmq_queue_messages 0 or rabbitmq_connections 12. If the endpoint is unreachable, check that port 15692 is open on your firewall or security group.

ℹ️ Two Endpoints to Know
  • /metrics (port 15692) — Default. Returns aggregated, cluster-level metrics. Low overhead. Recommended for most setups.
  • /metrics/detailed — Returns per-queue, per-channel, and per-consumer metrics. Higher overhead; use only when debugging specific objects.

Step 2: Configure Prometheus to Scrape RabbitMQ

Open your prometheus.yml configuration file and add a scrape job for RabbitMQ:

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'rabbitmq'
    scrape_interval: 10s
    scrape_timeout: 10s
    static_configs:
      - targets:
          - 'rabbitmq-node1:15692'
          - 'rabbitmq-node2:15692'
          - 'rabbitmq-node3:15692'
        labels:
          cluster: 'production'

Replace rabbitmq-node1, rabbitmq-node2, etc. with your actual hostnames or IP addresses. Because Prometheus queries each node independently on port 15692, the setup remains resilient even if one node is temporarily down.

Reload Prometheus

After editing prometheus.yml, reload Prometheus without a full restart:

curl -X POST http://localhost:9090/-/reload

Navigate to http://<prometheus-host>:9090/targets in your browser. Your RabbitMQ targets should appear with a green UP status.

Step 3: Key RabbitMQ Prometheus Metrics to Monitor

Once Prometheus is scraping RabbitMQ, you have access to hundreds of metrics. Focus on these critical categories first:

CategoryMetric NameWhat It Tells You
Queue depthrabbitmq_queue_messagesTotal messages in all queues
Queue depthrabbitmq_queue_messages_unackedDelivered but not yet acknowledged
Throughputrabbitmq_channel_messages_published_totalTotal messages published
Connectionsrabbitmq_connectionsTotal open client connections
Memoryrabbitmq_process_resident_memory_bytesNode resident memory usage
Diskrabbitmq_disk_space_available_bytesFree disk space on data partition

Step 4: Visualise Metrics in Grafana

Prometheus stores the raw time-series data. Grafana turns it into actionable dashboards.

Import the Official RabbitMQ Dashboard

1.  Open Grafana and go to Dashboards > Import.

2.  Enter dashboard ID 10991 (the RabbitMQ-Overview dashboard maintained by the RabbitMQ team) and click Load.

3.  Select your Prometheus data source and click Import.

You can also find the full dashboard JSON at: github.com/rabbitmq/rabbitmq-server … /dashboards

Useful PromQL Queries

Use these queries directly in Grafana panels or in the Prometheus Graph view:

# Message publish rate (per second, 5-minute window)
rate(rabbitmq_channel_messages_published_total[5m])

# Memory utilisation ratio
rabbitmq_process_resident_memory_bytes / rabbitmq_resident_memory_limit_bytes

# File descriptor utilisation ratio
rabbitmq_process_open_fds / rabbitmq_process_max_fds

# Total unacknowledged messages across all queues
sum(rabbitmq_queue_messages_unacked)

# Messages routed per second
rate(rabbitmq_queue_messages_published_total[5m])

Kubernetes: Enabling the Plugin with the RabbitMQ Cluster Operator

If you deploy RabbitMQ using the official Kubernetes Cluster Operator, the rabbitmq_prometheus plugin is enabled automatically. You still need to expose port 15692 and configure a Prometheus ServiceMonitor.

Expose the Metrics Port in Your RabbitMQ Service

apiVersion: v1
kind: Service
metadata:
  name: rabbitmq
  labels:
    app: rabbitmq
spec:
  ports:
    - name: amqp
      port: 5672
      targetPort: 5672
    - name: management
      port: 15672
      targetPort: 15672
    - name: prometheus-metrics
      port: 15692
      targetPort: 15692
  selector:
    app: rabbitmq

Create a Prometheus ServiceMonitor

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: rabbitmq
  namespace: monitoring
spec:
  selector:
    matchLabels:
      app: rabbitmq
  endpoints:
    - port: prometheus-metrics
      interval: 15s
      path: /metrics

If you use the kube-prometheus-stack Helm chart, you can also enable RabbitMQ metrics directly in the values file:

metrics:
  enabled: true
plugins: 'rabbitmq_prometheus'

Using the Configuration File Instead of the CLI

You can also pre-configure the plugin via rabbitmq.conf so it loads automatically on node startup. This is the preferred approach for immutable infrastructure:

# rabbitmq.conf
# Enable the Prometheus plugin
# (no separate rabbitmq-plugins command needed when listed here)

# Default scrape path
prometheus.path = /metrics

# Default TCP port
prometheus.tcp.port = 15692

# Return per-object metrics (default: false)
# Set to true only for debugging; impacts performance on large clusters
prometheus.return_per_object_metrics = false
⚠️ Performance Note
  • On clusters with 80,000+ queues, enabling per-object metrics (prometheus.return_per_object_metrics = true) has been observed to produce 1.9 million metrics in a ~98 MB response taking up to 58 seconds.
  • Keep the default (false) in production and use /metrics/detailed only for targeted debugging.

Management Plugin vs. Prometheus Plugin: Which Should You Use?

Many teams start with the Management Plugin API (port 15672). Here is why switching to the Prometheus plugin matters for production:

AspectManagement Plugin (15672)Prometheus Plugin (15692)
OverheadHigher (queries all nodes)Low (local node data only)
Data retentionRecent data only (hours)Long-term (years, with Prometheus)
Cluster queriesAggregates across all nodesPer-node; use service discovery
Recommended forDevelopment / UI accessProduction monitoring
Auth modelRabbitMQ user/tag systemNetwork-level (no RabbitMQ auth)
Metrics formatJSON via HTTP APIPrometheus text format

Alerting on Critical RabbitMQ Metrics

Add these alert rules to a rabbitmq_alerts.yml file and reference it from your prometheus.yml:

groups:
  - name: rabbitmq
    rules:

      # Alert if a queue grows beyond 10,000 unacked messages
      - alert: RabbitMQHighUnackedMessages
        expr: rabbitmq_queue_messages_unacked > 10000
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: 'High unacknowledged message count on {{ $labels.queue }}'

      # Alert if memory usage exceeds 80% of the limit
      - alert: RabbitMQHighMemoryUsage
        expr: >
          rabbitmq_process_resident_memory_bytes
          / rabbitmq_resident_memory_limit_bytes > 0.80
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: 'RabbitMQ memory usage above 80% on {{ $labels.instance }}'

      # Alert if file descriptor usage exceeds 85%
      - alert: RabbitMQHighFileDescriptorUsage
        expr: >
          rabbitmq_process_open_fds
          / rabbitmq_process_max_fds > 0.85
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: 'File descriptor usage high on {{ $labels.instance }}'

Troubleshooting Common Issues

Port 15692 not reachable

  • Confirm the plugin is enabled: rabbitmq-plugins list | grep prometheus
  • Check your firewall or security group allows inbound TCP on port 15692 from the Prometheus host.
  • Ensure no other process is bound to port 15692.

Prometheus target shows DOWN

  • Verify the target address in prometheus.yml exactly matches the RabbitMQ host and port.
  • Try curling the /metrics endpoint from the Prometheus host itself.
  • Check network policies in Kubernetes if using a ServiceMonitor.

No per-queue metrics visible

By default the plugin returns aggregated metrics only. To see per-queue data, scrape /metrics/detailed or set prometheus.return_per_object_metrics = true in rabbitmq.conf. Be aware of the performance implications on large clusters.

Metrics endpoint returns 404

Confirm the correct path. The default path is /metrics, not /api/metrics. The /api/metrics path belongs to the Management Plugin on port 15672, not the Prometheus plugin on port 15692.

Quick Reference Summary

# 1. Enable the plugin
rabbitmq-plugins enable rabbitmq_prometheus

# 2. Verify the endpoint
curl http://localhost:15692/metrics

# 3. Detailed (per-object) metrics
curl http://localhost:15692/metrics/detailed

# 4. Prometheus scrape config (prometheus.yml)
scrape_configs:
  - job_name: 'rabbitmq'
    static_configs:
      - targets: ['<rabbitmq-host>:15692']

# 5. Grafana dashboard import ID
10991
Monitor RabbitMQ Smarter with CubeAPM
Once your RabbitMQ metrics are flowing into Prometheus, the next step is making sense of them. CubeAPM is an OpenTelemetry-native APM and observability platform that works seamlessly with Prometheus scraping, letting you correlate RabbitMQ queue depths, message rates, and connection counts with your application traces and logs, all in one place.
Why teams choose CubeAPM for RabbitMQ observability:
  • Drop-in Prometheus compatibility, no agent rewrites needed
  • Correlate queue lag spikes directly with slow consumer traces
  • Pre-built RabbitMQ dashboards so you are productive from day one
  • Alerting on consumer lag, memory pressure, and connection saturation
  • Self-hosted or cloud, with a generous free tier
Try CubeAPM Free →

FAQs

Q1: What port does RabbitMQ expose Prometheus metrics on? 

Port 15692 at the /metrics endpoint. This is separate from the Management UI port (15672).

Q2: Do I need to restart RabbitMQ after enabling the Prometheus plugin?

No. Running rabbitmq-plugins enable rabbitmq_prometheus activates the plugin immediately without a restart.

Q3: What is the difference between /metrics and /metrics/detailed? 

/metrics returns aggregated, cluster-level data and is low overhead. /metrics/detailed returns per-queue, per-channel, and per-consumer breakdowns but is significantly heavier on large clusters.

Q4: Can I use the Management Plugin instead of the Prometheus plugin for monitoring?

You can, but it is not recommended for production. The Management Plugin has higher overhead, stores only recent data, and queries all nodes simultaneously. The Prometheus plugin queries each node locally, making it faster and more resilient.

Q5: Does the Prometheus plugin work with Kubernetes?

Yes. The RabbitMQ Cluster Operator enables the plugin automatically. You just need to expose port 15692 via a Kubernetes Service and configure a Prometheus ServiceMonitor to scrape it.

×
×