Monitor RabbitMQ running on Linux hosts by installing and configuring the OpenTelemetry Collector. This comprehensive guide walks you through installation, configuration, and verification for Debian, Ubuntu, RHEL, and CentOS systems.
Installation steps
Follow these steps in order to set up monitoring for your self-hosted RabbitMQ instance.
Before you begin
Make sure your environment meets these requirements:
Enable the RabbitMQ management plugin
The management plugin exposes the API that the OpenTelemetry Collector scrapes:
$sudo rabbitmq-plugins enable rabbitmq_managementVerify it's working:
$curl -I -u admin:password http://localhost:15672/api/overviewYou should see HTTP/1.1 200 OK in the response.
Install the OpenTelemetry Collector
For all Linux distribution:
Download and install the OpenTelemetry Collector Contrib binary for your host operating system from the OpenTelemetry Collector releases.
Configure the collector
Create or replace /etc/otelcol-contrib/config.yaml:
receivers: rabbitmq: endpoint: http://localhost:15672 username: admin password: password collection_interval: 30s metrics: # Queue Metrics (essential for message flow and backlog) rabbitmq.consumer.count: enabled: true rabbitmq.message.delivered: enabled: true rabbitmq.message.published: enabled: true rabbitmq.message.acknowledged: enabled: true rabbitmq.message.dropped: enabled: true rabbitmq.message.current: enabled: true # Crucial for monitoring queue backlog, includes 'ready' and 'unacknowledged' states
# Node Health Metrics (critical for server resource monitoring) rabbitmq.node.disk_free: enabled: true rabbitmq.node.disk_free_limit: enabled: true rabbitmq.node.disk_free_alarm: enabled: true rabbitmq.node.mem_used: enabled: true rabbitmq.node.mem_limit: enabled: true rabbitmq.node.mem_alarm: enabled: true rabbitmq.node.mem_used_details.rate: enabled: true rabbitmq.node.fd_used: enabled: true rabbitmq.node.fd_total: enabled: true rabbitmq.node.sockets_used: enabled: true rabbitmq.node.sockets_total: enabled: true rabbitmq.node.proc_used: enabled: true rabbitmq.node.proc_total: enabled: true rabbitmq.node.uptime: enabled: true rabbitmq.node.run_queue: enabled: true rabbitmq.node.processors: enabled: true rabbitmq.node.context_switches_details.rate: enabled: true rabbitmq.node.gc_num_details.rate: enabled: true rabbitmq.node.gc_bytes_reclaimed_details.rate: enabled: true
# I/O Metrics (important for understanding disk and network activity) rabbitmq.node.io_read_count_details.rate: enabled: true rabbitmq.node.io_read_bytes_details.rate: enabled: true rabbitmq.node.io_read_avg_time_details.rate: enabled: true rabbitmq.node.io_write_count_details.rate: enabled: true rabbitmq.node.io_write_bytes_details.rate: enabled: true rabbitmq.node.io_write_avg_time_details.rate: enabled: true rabbitmq.node.io_sync_count_details.rate: enabled: true rabbitmq.node.io_sync_avg_time_details.rate: enabled: true rabbitmq.node.io_seek_count_details.rate: enabled: true rabbitmq.node.io_seek_avg_time_details.rate: enabled: true rabbitmq.node.io_reopen_count_details.rate: enabled: true
# Mnesia and Store Metrics (for internal database and message storage) rabbitmq.node.mnesia_ram_tx_count_details.rate: enabled: true rabbitmq.node.mnesia_disk_tx_count_details.rate: enabled: true rabbitmq.node.msg_store_read_count_details.rate: enabled: true rabbitmq.node.msg_store_write_count_details.rate: enabled: true rabbitmq.node.queue_index_write_count_details.rate: enabled: true rabbitmq.node.queue_index_read_count_details.rate: enabled: true
# Connection/Channel/Queue Lifecycle Metrics rabbitmq.node.connection_created_details.rate: enabled: true rabbitmq.node.connection_closed_details.rate: enabled: true rabbitmq.node.channel_created_details.rate: enabled: true rabbitmq.node.channel_closed_details.rate: enabled: true rabbitmq.node.queue_declared_details.rate: enabled: true rabbitmq.node.queue_created_details.rate: enabled: true rabbitmq.node.queue_deleted_details.rate: enabled: true
# processors: Process data before exporting.processors: resourcedetection: detectors: [system] system: resource_attributes: host.name: enabled: true host.id: enabled: true resource: attributes: - key: instrumentation.provider value: opentelemetry action: upsert - key: rabbitmq.deployment.name value: my-rabbitmq-server # Replace with your server name action: upsert batch: send_batch_size: 1024 timeout: 30s
exporters: otlphttp/newrelic: endpoint: ${env:NEWRELIC_OTLP_ENDPOINT} headers: api-key: ${env:NEWRELIC_LICENSE_KEY} compression: gzip
service: pipelines: metrics: receivers: [rabbitmq] processors: [resourcedetection, resource, batch] exporters: [otlphttp/newrelic]Update these values in the configuration:
endpoint: Your RabbitMQ management API URL (default:http://localhost:15672)usernameandpassword: Your RabbitMQ credentialsrabbitmq.deployment.name: A unique name for this RabbitMQ instancecollection_interval: How often to scrape metrics (default: 30 seconds)
Set environment variables
Create a systemd override file for environment variables:
$sudo mkdir -p /etc/systemd/system/otelcol-contrib.service.dChoose your New Relic region:
$cat <<EOF | sudo tee /etc/systemd/system/otelcol-contrib.service.d/environment.conf$[Service]$Environment="NEWRELIC_OTLP_ENDPOINT=https://otlp.nr-data.net:4318"$Environment="NEWRELIC_LICENSE_KEY=YOUR_LICENSE_KEY"$EOFReplace YOUR_LICENSE_KEY with your New Relic license key.
$cat <<EOF | sudo tee /etc/systemd/system/otelcol-contrib.service.d/environment.conf$[Service]$Environment="NEWRELIC_OTLP_ENDPOINT=https://otlp.eu01.nr-data.net:4318"$Environment="NEWRELIC_LICENSE_KEY=YOUR_LICENSE_KEY"$EOFReplace YOUR_LICENSE_KEY with your New Relic license key.
Reload systemd and restart the collector:
$sudo systemctl daemon-reload$sudo systemctl restart otelcol-contribVerify your data in New Relic
Check the service status:
$sudo systemctl status otelcol-contribYou should see active (running) in the output.
View recent logs:
$sudo journalctl -u otelcol-contrib -n 50 --no-pagerLook for messages indicating successful metric collection:
INFO RabbitmqReceiver Successfully scraped rabbitmq metricsVerify metrics in New Relic:
Wait 2-3 minutes for data to appear, then run this query in the query builder:
SELECT count(*)FROM MetricWHERE metricName LIKE 'rabbitmq.%' AND instrumentation.provider = 'opentelemetry' AND rabbitmq.deployment.name = 'my-rabbitmq-server'FACET metricNameSINCE 10 minutes agoYou should see metric names like:
rabbitmq.queue.count- Number of queuesrabbitmq.queue.message.count- Total messages across queuesrabbitmq.connection.count- Active connectionsrabbitmq.consumer.count- Active consumers
Tip
If you don't see data after 5 minutes, check the troubleshooting section below.
(Optional) Forward RabbitMQ logs to New Relic
In addition to metrics, you can forward RabbitMQ application logs to New Relic for comprehensive observability. This helps correlate issues across metrics and logs.
Important
Log forwarding requires additional configuration and system permissions. Ensure you have the necessary access before proceeding.
Update /etc/otelcol-contrib/config.yaml to add the filelog receiver:
receivers: rabbitmq: # ... existing rabbitmq config ...
# Add filelog receiver for RabbitMQ logs filelog/rabbitmq: include: - /var/log/rabbitmq/*.log - /var/log/rabbitmq/**/*.log include_file_path: true include_file_name: false operators: - type: regex_parser regex: '^(?P<timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}) \[(?P<level>\w+)\] <(?P<pid>[^>]+)> (?P<message>.*)$' timestamp: parse_from: attributes.timestamp layout: '%Y-%m-%d %H:%M:%S.%L' severity: parse_from: attributes.severity
processors: # ... existing processors ...
transform/rabbitmq_logs: log_statements: - context: resource statements: - set(attributes["rabbitmq.display.name"], Concat(["server", attributes["rabbitmq.deployment.name"]], ":"))
service: pipelines: metrics: receivers: [rabbitmq] processors: [resourcedetection, resource, batch] exporters: [otlphttp/newrelic]
logs/rabbitmq: receivers: [filelog] processors: [batch, resource, transform/rabbitmq_logs] exporters: [otlphttp/newrelic]Grant the collector permission to read logs. Choose one method:
Add to rabbitmq group:
$sudo usermod -a -G rabbitmq otelcol-contribOr set file permissions:
$sudo chmod 644 /var/log/rabbitmq/*.logRestart the collector:
$sudo systemctl restart otelcol-contribVerify logs are being collected in New Relic:
SELECT count(*)FROM LogWHERE service.name = 'rabbitmq' AND rabbitmq.deployment.name = 'my-rabbitmq-server'SINCE 10 minutes agoFind your data
After a few minutes, your RabbitMQ metrics should appear in New Relic. See Find and query your data for detailed instructions on exploring your RabbitMQ metrics across different views in the New Relic UI.
You can also query your data with NRQL:
FROM Metric SELECT * WHERE rabbitmq.deployment.name = 'my-rabbitmq-server'Troubleshooting
Next steps
Now that you have RabbitMQ monitoring set up, you can enhance your observability:
Explore your data:
- Find and query your data - Navigate New Relic UI and write NRQL queries
- Explore RabbitMQ metrics - Complete metrics reference with alerting recommendations
Enhance monitoring:
- Create alerts - Set up alerts for queue depths and message backlogs
- Build dashboards - Create custom dashboards to visualize your RabbitMQ metrics