# Monitoring and Resource Alarms — RabbitMQ

Source: https://www.skillbyai.com/en/rabbitmq/o-monitor

> Monitor queues, consumers and node resources, and understand flow control.

## Know before the queue explodes

Key signals: **queue depth** (ready messages) and **unacknowledged** messages per queue; **publish, deliver and ack rates**; **consumer count** per queue (a queue with no consumers is a growing problem); **redelivery** rates; **connection and channel counts** (churn indicates clients opening connections per message, a common mistake); and node **memory, disk, file descriptors and Erlang processes**. RabbitMQ protects itself with **resource alarms**: when memory use passes the **high watermark** (by default a fraction of available RAM) or free disk falls below the **disk free limit**, the broker **blocks publishing connections** until the alarm clears, while consumers keep working. Before that, **credit-based flow control** slows down fast publishers when queues cannot keep up. Expose metrics through the **Prometheus plugin** (port 15692) with the official Grafana dashboards, and alert on growing queues, missing consumers, alarms and high redelivery.

## Useful alerts in PromQL

Metric names from the rabbitmq_prometheus plugin; per-queue series need its per-object (or detailed) endpoint.

```promql
# ready messages growing in a queue for 15 minutes
delta(rabbitmq_queue_messages_ready{queue="billing.orders"}[15m]) > 1000

# a queue with messages but no consumers
rabbitmq_queue_messages_ready > 0 and rabbitmq_queue_consumers == 0

# memory or disk alarm active on any node
rabbitmq_alarms_memory_used_watermark > 0 or rabbitmq_alarms_free_disk_space_watermark > 0

# connection churn (clients opening connections per message?)
rate(rabbitmq_connections_opened_total[5m]) > 10
```

## A dam with flood gates

When the reservoir (memory or disk) nears its limit, the dam closes the inlet gates (blocks publishers) while the turbines (consumers) keep running, until the level drops back to safe.

**Quiz:** What does RabbitMQ do when a node reaches its memory high watermark?

- [ ] Deletes the largest queue
- [x] Blocks publishing connections until memory drops, while consumers continue
- [ ] Shuts down immediately
- [ ] Converts queues to streams

*Answer:* Blocks publishing connections until memory drops, while consumers continue. Resource alarms block publishers to protect the broker while letting consumers drain queues.
