How to Monitor Your RabbitMQ Server with Vigilmon
RabbitMQ is a critical piece of infrastructure — it brokers messages between your services, handles background job queues, and keeps your microservices decoupled. When RabbitMQ goes down or degrades, the blast radius can be enormous: jobs stop processing, events get dropped, and your entire async processing pipeline freezes.
This guide shows you how to monitor RabbitMQ with Vigilmon using RabbitMQ's built-in management API.
RabbitMQ Management API — Your Best Monitoring Tool
The RabbitMQ Management Plugin ships with every RabbitMQ installation and provides a comprehensive REST API for monitoring:
# Enable management plugin (if not already enabled)
rabbitmq-plugins enable rabbitmq_management
Now you have access to:
-
GET /api/overview— Node overview (connections, queues, messages) -
GET /api/nodes— Detailed node health -
GET /api/queues— Queue depths and consumer counts -
GET /api/healthchecks/node— Built-in health check
Using the Built-in Health Check
RabbitMQ 3.9+ includes a native health check endpoint:
curl -u guest:guest http://localhost:15672/api/healthchecks/node
# Returns: {"status":"ok"}
Important: The management API runs on port 15672 by default. Never expose this publicly. Proxy it through your application.
Creating an Application Health Proxy
Node.js / Express
const axios = require('axios');
const RABBITMQ_MGMT = process.env.RABBITMQ_MGMT_URL || 'http://localhost:15672';
const RABBITMQ_USER = process.env.RABBITMQ_USER;
const RABBITMQ_PASS = process.env.RABBITMQ_PASS;
app.get('/health/rabbitmq', async (req, res) => {
try {
const [nodeHealth, overview] = await Promise.all([
axios.get(`${RABBITMQ_MGMT}/api/healthchecks/node`, {
auth: { username: RABBITMQ_USER, password: RABBITMQ_PASS },
timeout: 5000
}),
axios.get(`${RABBITMQ_MGMT}/api/overview`, {
auth: { username: RABBITMQ_USER, password: RABBITMQ_PASS },
timeout: 5000
})
]);
const stats = overview.data.queue_totals;
const isHealthy = nodeHealth.data.status === 'ok';
return res.status(isHealthy ? 200 : 503).json({
status: nodeHealth.data.status,
messages_ready: stats.messages_ready,
messages_unacked: stats.messages_unacknowledged,
consumers: overview.data.object_totals.consumers
});
} catch (err) {
return res.status(503).json({ status: 'error', error: err.message });
}
});
Python / Flask
import requests
from flask import Flask, jsonify
import os
app = Flask(__name__)
RABBITMQ_MGMT = os.environ.get('RABBITMQ_MGMT_URL', 'http://localhost:15672')
AUTH = (os.environ['RABBITMQ_USER'], os.environ['RABBITMQ_PASS'])
@app.route('/health/rabbitmq')
def health_rabbitmq():
try:
health = requests.get(
f'{RABBITMQ_MGMT}/api/healthchecks/node',
auth=AUTH, timeout=5
)
overview = requests.get(
f'{RABBITMQ_MGMT}/api/overview',
auth=AUTH, timeout=5
)
stats = overview.json().get('queue_totals', {})
is_healthy = health.json().get('status') == 'ok'
return jsonify({
'status': 'ok' if is_healthy else 'error',
'messages_ready': stats.get('messages_ready', 0),
'messages_unacked': stats.get('messages_unacknowledged', 0)
}), 200 if is_healthy else 503
except Exception as e:
return jsonify({'status': 'error', 'error': str(e)}), 503
Vigilmon Configuration for RabbitMQ
- Sign up at vigilmon.online
-
Add HTTP Monitor →
https://yourapp.com/health/rabbitmq - Check interval: 1 minute
- Expected status: 200
- Response time alert: 2000ms
TCP Port Monitor (Secondary)
RabbitMQ AMQP port is 5672. Add a TCP monitor:
- Host: your RabbitMQ server
- Port:
5672 - This catches RabbitMQ process crashes when your app might also be down
Advanced: Monitor Queue Depths
Queue depth explosions are a common failure mode — jobs queue up faster than workers process them:
app.get('/health/rabbitmq/queues', async (req, res) => {
try {
const response = await axios.get(
`${RABBITMQ_MGMT}/api/queues/%2F`, // %2F = default vhost
{ auth: { username: RABBITMQ_USER, password: RABBITMQ_PASS }, timeout: 5000 }
);
const queues = response.data.map(q => ({
name: q.name,
messages: q.messages,
consumers: q.consumers,
state: q.state
}));
// Alert if any queue exceeds threshold with 0 consumers
const backloggedQueues = queues.filter(
q => q.messages > 1000 && q.consumers === 0
);
const isHealthy = backloggedQueues.length === 0;
return res.status(isHealthy ? 200 : 503).json({
status: isHealthy ? 'ok' : 'degraded',
queues,
backlogged: backloggedQueues
});
} catch (err) {
return res.status(503).json({ status: 'error', error: err.message });
}
});
Common RabbitMQ Failure Modes
Memory Alarm
When RabbitMQ memory usage exceeds the threshold (default: 40% of system RAM), it blocks all producers:
# Check memory alarm
curl -u user:pass http://localhost:15672/api/nodes | jq '.[].mem_alarm'
# false = healthy, true = alarm active
Disk Alarm
When disk space falls below the free disk limit, RabbitMQ blocks all producers:
# Check disk alarm
curl -u user:pass http://localhost:15672/api/nodes | jq '.[].disk_free_alarm'
Dead Letter Queue Build-up
Messages rejected by consumers accumulate in dead letter queues. Monitor DLQ size:
const dlqDepth = queues.find(q => q.name.includes('dead-letter'))?.messages || 0;
if (dlqDepth > 100) {
// Alert: messages are failing processing
}
Split Brain (Mirrored Queues)
In clustered RabbitMQ, network partitions can cause split-brain. Check cluster health:
curl -u user:pass http://localhost:15672/api/nodes | jq '.[].partitions'
# Empty array = healthy, non-empty = partition detected
Alerting Matrix
| Scenario | Severity | Response |
|---|---|---|
| TCP 5672 not responding | P0 Critical | RabbitMQ process down |
| Health check returns 503 | P1 Critical | Node alarm or crash |
| Queue depth >10000 with 0 consumers | P1 Critical | Workers crashed |
| DLQ depth >1000 | P2 Warning | Review rejected messages |
| Memory alarm active | P1 Critical | Scale up or reduce load |
Production Checklist
- [ ] RabbitMQ Management Plugin enabled
- [ ]
/health/rabbitmqapplication proxy endpoint - [ ] TCP monitor on port 5672
- [ ] Queue depth monitor with consumer count check
- [ ] Dead letter queue depth alert
- [ ] Response time alert at 2000ms
- [ ] Memory and disk alarm monitoring
Start monitoring RabbitMQ for free with Vigilmon →
Vigilmon is an uptime monitoring platform for developers. Free tier includes 10 monitors with 1-minute checks from multiple global regions.
Top comments (0)