How to Use Prometheus with RabbitMQ for Monitoring
To use
Prometheus with RabbitMQ, enable the RabbitMQ Prometheus plugin which exposes metrics at an HTTP endpoint. Then configure Prometheus to scrape this endpoint by adding it to the prometheus.yml file under scrape_configs.Syntax
To integrate Prometheus with RabbitMQ, you need to enable the RabbitMQ Prometheus plugin and configure Prometheus to scrape metrics from RabbitMQ's HTTP endpoint.
The main parts are:
- Enable plugin:
rabbitmq-plugins enable rabbitmq_prometheus - Prometheus scrape config: Add RabbitMQ endpoint under
scrape_configsinprometheus.yml - Metrics endpoint: Usually
http://localhost:15692/metricsafter enabling the plugin
bash
rabbitmq-plugins enable rabbitmq_prometheus # prometheus.yml snippet scrape_configs: - job_name: 'rabbitmq' static_configs: - targets: ['localhost:15692']
Example
This example shows how to enable the RabbitMQ Prometheus plugin and configure Prometheus to scrape metrics from RabbitMQ.
bash
# Step 1: Enable the Prometheus plugin in RabbitMQ rabbitmq-plugins enable rabbitmq_prometheus # Step 2: Restart RabbitMQ server to apply changes sudo systemctl restart rabbitmq-server # Step 3: Add this to prometheus.yml configuration file scrape_configs: - job_name: 'rabbitmq' static_configs: - targets: ['localhost:15692'] # Step 4: Start Prometheus with the updated config ./prometheus --config.file=prometheus.yml
Output
Enabling plugins on node rabbit@localhost:
rabbitmq_prometheus enabled
# Prometheus starts and scrapes metrics from http://localhost:15692/metrics successfully
Common Pitfalls
- Not enabling the
rabbitmq_prometheusplugin will result in no metrics endpoint. - Forgetting to restart RabbitMQ after enabling the plugin means metrics won't be exposed.
- Incorrect Prometheus
targetsURL or port will cause scraping failures. - Firewall or network issues blocking port
15692prevent Prometheus from accessing metrics.
bash
## Wrong: Not enabling plugin # No metrics endpoint available ## Right: Enable plugin and restart rabbitmq-plugins enable rabbitmq_prometheus sudo systemctl restart rabbitmq-server
Quick Reference
| Step | Command/Config | Description |
|---|---|---|
| 1 | rabbitmq-plugins enable rabbitmq_prometheus | Enable Prometheus metrics plugin in RabbitMQ |
| 2 | sudo systemctl restart rabbitmq-server | Restart RabbitMQ to apply plugin changes |
| 3 | Add to prometheus.yml | Configure Prometheus to scrape RabbitMQ metrics endpoint |
| 4 | Start Prometheus | Run Prometheus with updated config to collect metrics |
Key Takeaways
Enable the rabbitmq_prometheus plugin to expose metrics for Prometheus.
Restart RabbitMQ after enabling the plugin to activate metrics endpoint.
Configure Prometheus scrape_configs to target RabbitMQ's metrics HTTP endpoint.
Ensure network access to RabbitMQ metrics port (default 15692) for Prometheus scraping.
Verify Prometheus logs to confirm successful scraping of RabbitMQ metrics.