0
0
RabbitmqHow-ToBeginner ยท 4 min read

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_configs in prometheus.yml
  • Metrics endpoint: Usually http://localhost:15692/metrics after 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_prometheus plugin will result in no metrics endpoint.
  • Forgetting to restart RabbitMQ after enabling the plugin means metrics won't be exposed.
  • Incorrect Prometheus targets URL or port will cause scraping failures.
  • Firewall or network issues blocking port 15692 prevent 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

StepCommand/ConfigDescription
1rabbitmq-plugins enable rabbitmq_prometheusEnable Prometheus metrics plugin in RabbitMQ
2sudo systemctl restart rabbitmq-serverRestart RabbitMQ to apply plugin changes
3Add to prometheus.ymlConfigure Prometheus to scrape RabbitMQ metrics endpoint
4Start PrometheusRun 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.