Monitoring
Monitoring
Section titled “Monitoring”Monitor RabbitMQ health, performance, and message flow for Mantis deployments.
Overview
Section titled “Overview”Management Interface
Section titled “Management Interface”Enable Management Plugin
Section titled “Enable Management Plugin”sudo rabbitmq-plugins enable rabbitmq_managementAccess Management UI
Section titled “Access Management UI”| Environment | URL | Default Port |
|---|---|---|
| HTTP | http://localhost:15672 | 15672 |
| HTTPS | https://localhost:15671 | 15671 |
Key Dashboards
Section titled “Key Dashboards”| Tab | Metrics |
|---|---|
| Overview | Message rates, queued messages, connections |
| Connections | Connection count, channels, throughput |
| Channels | Channel state, prefetch, unacknowledged |
| Exchanges | Message rates per exchange |
| Queues | Queue depth, consumers, rates |
Command-Line Monitoring
Section titled “Command-Line Monitoring”Cluster Status
Section titled “Cluster Status”# Overall cluster healthsudo rabbitmqctl cluster_status
# Node health checksudo rabbitmqctl node_health_check
# Cluster alarmssudo rabbitmqctl list_alarmsConnection Monitoring
Section titled “Connection Monitoring”# List all connectionssudo rabbitmqctl list_connections name state channels
# Connection detailssudo rabbitmqctl list_connections \ name peer_host peer_port state \ channels recv_oct send_oct
# Connections by applicationsudo rabbitmqctl list_connections client_properties | grep productChannel Monitoring
Section titled “Channel Monitoring”# List channelssudo rabbitmqctl list_channels name connection state
# Channel details with prefetchsudo rabbitmqctl list_channels \ name connection prefetch_count \ messages_unacknowledged messages_uncommittedQueue Monitoring
Section titled “Queue Monitoring”# Queue summarysudo rabbitmqctl list_queues name messages consumers
# Detailed queue statssudo rabbitmqctl list_queues \ name messages messages_ready messages_unacknowledged \ consumers memory state
# Mantis-specific queuessudo rabbitmqctl list_queues name messages consumers \ | grep mantisExchange Monitoring
Section titled “Exchange Monitoring”# List exchangessudo rabbitmqctl list_exchanges name type
# Exchange message ratessudo rabbitmqctl list_exchanges name type \ message_stats.publish_in message_stats.publish_outConsumer Monitoring
Section titled “Consumer Monitoring”# List consumerssudo rabbitmqctl list_consumers queue consumer_tag channel_pid ack_required
# Mantis consumerssudo rabbitmqctl list_consumers | grep thoraxPrometheus Integration
Section titled “Prometheus Integration”Enable Prometheus Plugin
Section titled “Enable Prometheus Plugin”sudo rabbitmq-plugins enable rabbitmq_prometheusConfigure Prometheus Endpoint
Section titled “Configure Prometheus Endpoint”# Prometheus metrics endpointprometheus.tcp.port = 15692prometheus.return_per_object_metrics = trueKey Metrics
Section titled “Key Metrics”| Metric | Description |
|---|---|
rabbitmq_connections | Total connections |
rabbitmq_channels | Total channels |
rabbitmq_queue_messages | Messages in queue |
rabbitmq_queue_consumers | Consumers per queue |
rabbitmq_queue_messages_ready | Ready for delivery |
rabbitmq_queue_messages_unacknowledged | In-flight messages |
Prometheus Scrape Config
Section titled “Prometheus Scrape Config”scrape_configs: - job_name: 'rabbitmq' static_configs: - targets: ['rabbitmq:15692'] metrics_path: /metrics scrape_interval: 15sPer-Queue Metrics
Section titled “Per-Queue Metrics”# Enable detailed queue metricsscrape_configs: - job_name: 'rabbitmq-detailed' static_configs: - targets: ['rabbitmq:15692'] metrics_path: /metrics/detailed params: family: [queue_metrics, exchange_metrics]Grafana Dashboards
Section titled “Grafana Dashboards”RabbitMQ Overview Dashboard
Section titled “RabbitMQ Overview Dashboard”Import dashboard ID: 10991 (RabbitMQ Overview)
Key panels:
- Message rates (publish/deliver)
- Queue depths
- Connection counts
- Memory and disk usage
Custom Mantis Dashboard
Section titled “Custom Mantis Dashboard”{ "title": "Mantis RabbitMQ", "panels": [ { "title": "Command Queue Depth", "targets": [ { "expr": "rabbitmq_queue_messages{queue=~\"mantis.commands.*\"}" } ] }, { "title": "Analysis Queue Depth", "targets": [ { "expr": "rabbitmq_queue_messages{queue=\"mantis.analysis\"}" } ] }, { "title": "Dead Letter Queue", "targets": [ { "expr": "rabbitmq_queue_messages{queue=\"mantis.dlq\"}" } ] }, { "title": "Thorax Consumers", "targets": [ { "expr": "rabbitmq_queue_consumers{queue=\"mantis.commands.thorax\"}" } ] } ]}Alerting
Section titled “Alerting”Prometheus Alert Rules
Section titled “Prometheus Alert Rules”groups: - name: rabbitmq rules: - alert: RabbitMQDown expr: up{job="rabbitmq"} == 0 for: 1m labels: severity: critical annotations: summary: 'RabbitMQ is down'
- alert: RabbitMQHighMemory expr: rabbitmq_process_resident_memory_bytes > 2147483648 for: 5m labels: severity: warning annotations: summary: 'RabbitMQ memory usage high'
- alert: RabbitMQQueueBacklog expr: rabbitmq_queue_messages{queue=~"mantis.*"} > 1000 for: 5m labels: severity: warning annotations: summary: 'Queue {{ $labels.queue }} has backlog'
- alert: RabbitMQNoConsumers expr: rabbitmq_queue_consumers{queue="mantis.commands.thorax"} == 0 for: 2m labels: severity: critical annotations: summary: 'No consumers for command queue'
- alert: RabbitMQDeadLetterGrowing expr: increase(rabbitmq_queue_messages{queue="mantis.dlq"}[5m]) > 10 for: 5m labels: severity: warning annotations: summary: 'Dead letter queue growing'
- alert: RabbitMQHighUnacked expr: rabbitmq_queue_messages_unacknowledged > 100 for: 5m labels: severity: warning annotations: summary: 'High unacknowledged message count'Alertmanager Configuration
Section titled “Alertmanager Configuration”route: group_by: ['alertname'] group_wait: 30s group_interval: 5m repeat_interval: 4h receiver: 'ops-team' routes: - match: severity: critical receiver: 'ops-team-critical'
receivers: - name: 'ops-team' email_configs: - to: 'ops@example.com' - name: 'ops-team-critical' pagerduty_configs: - service_key: '<service-key>'Health Checks
Section titled “Health Checks”RabbitMQ Health Endpoint
Section titled “RabbitMQ Health Endpoint”# Basic health checkcurl -s http://localhost:15672/api/healthchecks/node | jq
# Cluster healthcurl -s http://localhost:15672/api/health/checks/alarms | jqThorax Health Integration
Section titled “Thorax Health Integration”Thorax reports RabbitMQ health via its HTTP health endpoint on port 9090 (port 50051 is the gRPC port and is not curl-able as JSON):
curl -s http://localhost:9090/health | jq '.queue'Response:
{ "healthy": true, "mode": "RabbitMQ", "consecutive_failures": 0}Docker Health Check
Section titled “Docker Health Check”services: rabbitmq: healthcheck: test: ['CMD', 'rabbitmq-diagnostics', '-q', 'ping'] interval: 30s timeout: 10s retries: 3Kubernetes Probes
Section titled “Kubernetes Probes”livenessProbe: exec: command: - rabbitmq-diagnostics - -q - ping initialDelaySeconds: 60 periodSeconds: 60 timeoutSeconds: 15readinessProbe: exec: command: - rabbitmq-diagnostics - -q - check_running initialDelaySeconds: 20 periodSeconds: 10 timeoutSeconds: 10Message Tracing
Section titled “Message Tracing”Enable Firehose
Section titled “Enable Firehose”For debugging message flow:
# Enable firehose (development only)sudo rabbitmq-plugins enable rabbitmq_tracing
# Create tracesudo rabbitmqctl trace_onMessage Headers
Section titled “Message Headers”Inspect message headers for debugging:
# Get messages with headersrabbitmqadmin get queue=mantis.commands.thorax count=1 ackmode=ack_requeue_false
# Check x-death headers for retry inforabbitmqadmin get queue=mantis.dlq count=1 | jq '.payload_bytes'Performance Metrics
Section titled “Performance Metrics”Message Rates
Section titled “Message Rates”# Global message ratessudo rabbitmqctl list_queues name \ message_stats.publish_details.rate \ message_stats.deliver_details.rate
# Queue-specific ratessudo rabbitmqctl list_queues name messages_ready \ message_stats.ack_details.rate \ | grep mantisThroughput Testing
Section titled “Throughput Testing”# Using PerfTest tooldocker run -it --rm --network host \ pivotalrabbitmq/perf-test:latest \ --uri amqp://mantis:password@localhost \ --producers 1 --consumers 2 \ --queue "test-queue" \ --time 60Memory Analysis
Section titled “Memory Analysis”# Memory breakdownsudo rabbitmqctl status | grep -A 20 memory
# Per-queue memorysudo rabbitmqctl list_queues name memoryLogging
Section titled “Logging”Configure Logging
Section titled “Configure Logging”# Log to console and filelog.console = truelog.console.level = info
log.file = /var/log/rabbitmq/rabbit.loglog.file.level = infolog.file.rotation.date = $D0log.file.rotation.count = 7
# Connection eventslog.connection.level = info
# Channel eventslog.channel.level = warningLog Analysis
Section titled “Log Analysis”# Recent errorsgrep -i error /var/log/rabbitmq/rabbit*.log | tail -20
# Connection issuesgrep -E "(connection|closed|refused)" /var/log/rabbitmq/rabbit*.log
# Authentication failuresgrep -i "access refused" /var/log/rabbitmq/rabbit*.logStructured Logging
Section titled “Structured Logging”# Enable JSON logginglog.console.formatter = jsonlog.file.formatter = jsonMonitoring Scripts
Section titled “Monitoring Scripts”Queue Depth Alert
Section titled “Queue Depth Alert”#!/bin/bashTHRESHOLD=1000QUEUE="mantis.commands.thorax"
DEPTH=$(sudo rabbitmqctl list_queues name messages \ | grep "$QUEUE" | awk '{print $2}')
if [ "$DEPTH" -gt "$THRESHOLD" ]; then echo "ALERT: Queue $QUEUE depth is $DEPTH (threshold: $THRESHOLD)" exit 1fi
echo "OK: Queue $QUEUE depth is $DEPTH"exit 0Consumer Health Check
Section titled “Consumer Health Check”#!/bin/bashQUEUE="mantis.commands.thorax"MIN_CONSUMERS=1
CONSUMERS=$(sudo rabbitmqctl list_queues name consumers \ | grep "$QUEUE" | awk '{print $2}')
if [ "$CONSUMERS" -lt "$MIN_CONSUMERS" ]; then echo "ALERT: Queue $QUEUE has $CONSUMERS consumers (minimum: $MIN_CONSUMERS)" exit 2fi
echo "OK: Queue $QUEUE has $CONSUMERS consumers"exit 0DLQ Monitor
Section titled “DLQ Monitor”#!/bin/bashDLQ="mantis.dlq"THRESHOLD=10
MESSAGES=$(sudo rabbitmqctl list_queues name messages \ | grep "$DLQ" | awk '{print $2}')
if [ "$MESSAGES" -gt "$THRESHOLD" ]; then echo "WARNING: DLQ has $MESSAGES messages"
# Get sample message for debugging rabbitmqadmin get queue=$DLQ count=1 2>/dev/null
exit 1fi
echo "OK: DLQ has $MESSAGES messages"exit 0Operational Dashboards
Section titled “Operational Dashboards”Real-Time Monitoring
Section titled “Real-Time Monitoring”# Watch queue depthswatch -n 5 'sudo rabbitmqctl list_queues name messages | grep mantis'
# Watch consumerswatch -n 5 'sudo rabbitmqctl list_consumers | grep thorax'
# Watch connectionswatch -n 5 'sudo rabbitmqctl list_connections name state | head -20'Nagios/Icinga Integration
Section titled “Nagios/Icinga Integration”# NRPE check commandcommand[check_rabbitmq_queue]=/opt/mantis/scripts/check-queue-depth.shcommand[check_rabbitmq_consumers]=/opt/mantis/scripts/check-consumers.shcommand[check_rabbitmq_dlq]=/opt/mantis/scripts/check-dlq.shTroubleshooting
Section titled “Troubleshooting”High Memory Usage
Section titled “High Memory Usage”-
Check queue depths:
Terminal window sudo rabbitmqctl list_queues name messages memory | sort -k3 -n -r | head -
Check for lazy queues:
Terminal window sudo rabbitmqctl list_queues name arguments | grep x-queue-mode -
Purge non-critical queues if needed:
Terminal window sudo rabbitmqctl purge_queue queue_name
Message Accumulation
Section titled “Message Accumulation”-
Check consumer health:
Terminal window sudo rabbitmqctl list_consumers -
Check for slow consumers:
Terminal window sudo rabbitmqctl list_channels prefetch_count messages_unacknowledged -
Review Thorax logs for processing errors
Connection Storms
Section titled “Connection Storms”-
Monitor connection rate:
Terminal window watch -n 1 'sudo rabbitmqctl list_connections | wc -l' -
Identify problematic clients:
Terminal window sudo rabbitmqctl list_connections peer_host | sort | uniq -c | sort -rn -
Enable connection throttling:
# rabbitmq.confconnection_max = 1000
Next Steps
Section titled “Next Steps”- Queue Topology - Queue structure
- TLS Configuration - Secure connections
- RabbitMQ Setup - Initial setup
