Home/Learn/RabbitMQ/Monitoring & Alerting

Monitoring & Alerting

Intermediate
Operations

Key metrics: queue depth, consumer count, unacknowledged messages, publish/deliver rates, and memory/disk alarms; export via prometheus exporter or HTTP API scraping.

Overview

RabbitMQ exposes rich operational metrics via the Management HTTP API and natively via the Prometheus plugin (rabbitmq_prometheus). Key signals fall into four categories: queue health (depth, consumer count, unacked messages), throughput (publish rate, deliver rate, redeliver rate), resource pressure (memory watermark, disk free alarm, file descriptor usage), and connection health (connection count, channel count, blocked connections). A growing queue depth with falling consumer count is the most important early warning signal — it indicates consumers are slower than producers or have crashed entirely. Prometheus + Grafana dashboards (official RabbitMQ Grafana dashboard ID 10991) provide instant visibility; Alertmanager rules on queue depth and consumer count prevent silent backlogs from overwhelming the broker.

Enabling the Prometheus plugin

The rabbitmq_prometheus plugin ships with RabbitMQ 3.8+. Enable it and scrape /metrics on port 15692 from Prometheus.

YAML — Prometheus plugin + scrape config
# Enable plugins (rabbitmq-plugins or environment variable)
rabbitmq-plugins enable rabbitmq_prometheus rabbitmq_management

# rabbitmq.conf
## Prometheus scrape port
prometheus.tcp.port = 15692

# prometheus.yml scrape config
scrape_configs:
  - job_name: rabbitmq
    static_configs:
      - targets: ['rabbitmq-host:15692']
    metrics_path: /metrics
    relabel_configs:
      - source_labels: [__address__]
        target_label: instance

# Key metrics exposed
# rabbitmq_queue_messages_ready          — messages waiting to be delivered
# rabbitmq_queue_messages_unacked_total  — delivered but not yet acked
# rabbitmq_queue_consumers               — active consumer count
# rabbitmq_channel_publish_total         — publish rate (use rate())
# rabbitmq_node_mem_used_bytes           — broker memory usage
# rabbitmq_node_disk_free_bytes          — free disk space

Critical Prometheus alert rules

These alert rules cover the most common RabbitMQ failure modes: queue backlog growth, consumer disappearance, memory pressure, and high redelivery rate (indicating poison messages).

YAML — Prometheus alert rules
groups:
  - name: rabbitmq
    rules:
      # Queue growing faster than consumers can drain
      - alert: RabbitMQQueueDepthHigh
        expr: rabbitmq_queue_messages_ready > 1000
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "Queue {{ $labels.queue }} has {{ $value }} messages"

      # No consumers — messages will pile up
      - alert: RabbitMQNoConsumers
        expr: rabbitmq_queue_consumers == 0
          and rabbitmq_queue_messages_ready > 0
        for: 2m
        labels:
          severity: critical
        annotations:
          summary: "Queue {{ $labels.queue }} has no consumers!"

      # Memory watermark — broker will block publishers
      - alert: RabbitMQMemoryAlarm
        expr: rabbitmq_alarms_memory_used_watermark > 0
        for: 0m
        labels:
          severity: critical

      # High redeliver rate = consumers nacking messages repeatedly (poison pill?)
      - alert: RabbitMQHighRedeliveryRate
        expr: rate(rabbitmq_queue_messages_redelivered_total[5m]) > 10
        for: 5m
        labels:
          severity: warning

HTTP API health checks from Spring Boot

Use the RabbitMQ Management HTTP API to poll queue stats programmatically — useful for auto-scaling decisions or health probes.

Java — RabbitMQ Management API health indicator
// Spring Boot: custom health indicator using Management HTTP API
@Component
public class RabbitQueueHealthIndicator implements HealthIndicator {

    private final RestTemplate rest = new RestTemplate();
    private final String mgmtUrl = "http://rabbitmq:15672/api/queues/%2F/orders.queue";

    @Override
    public Health health() {
        try {
            ResponseEntity<Map> resp = rest.withBasicAuth("guest", "guest")
                .getForEntity(mgmtUrl, Map.class);
            Map body = resp.getBody();
            int depth = (Integer) body.get("messages_ready");
            int consumers = (Integer) body.get("consumers");

            if (consumers == 0) {
                return Health.down()
                    .withDetail("reason", "No consumers")
                    .withDetail("depth", depth).build();
            }
            return Health.up()
                .withDetail("depth", depth)
                .withDetail("consumers", consumers).build();
        } catch (Exception e) {
            return Health.down(e).build();
        }
    }
}

Key Points to Remember

  • 1Enable rabbitmq_prometheus plugin — it is built-in since 3.8 and far more efficient than polling the HTTP API.
  • 2The three most important metrics: queue depth (messages_ready), consumer count, and unacked message count.
  • 3A memory alarm blocks all publishers — alert immediately; a disk alarm blocks publishes too when free space drops below threshold.
  • 4High redeliver rate indicates poison messages cycling through; check your DLQ and consumer logs immediately.
  • 5Import the official RabbitMQ Grafana dashboard (ID 10991) for a complete operational overview out of the box.
  • 6Use Spring Boot Actuator /health to surface queue health in Kubernetes liveness/readiness probes.

Interview Questions

Sign in to ask Aria
1

What is the difference between messages_ready and messages_unacknowledged in RabbitMQ metrics?

EasyPivotal
2

How would you set up an alert that fires when a queue has no consumers and more than 100 messages?

MediumZalando
3

What happens when RabbitMQ hits its memory watermark and how do you prevent it from affecting producers?

HardVMware
4

A queue depth is growing even though consumer count is healthy. What would you investigate?

MediumAmazon
5

How does the rabbitmq_prometheus plugin differ from scraping the /api/overview HTTP endpoint?

MediumGrafana Labs

Ask Aria about Monitoring & Alerting

Your personal AI tutor — ask anything about this concept

Revision Status

Personal Notes

Sign in to save personal notes for this topic.

Discussion

Sign in to join the discussion.

Loading discussion…