Skip to main content

Monitor RabbitMQ using Last9

Send RabbitMQ metrics to Last9

Introduction

This document lists step-by-step instructions for setting up monitoring for RabbitMQ using Last9.

Prerequisites

Create a Last9 cluster by following Getting Started.

Keep the following information handy after creating the cluster:

  • $levitate_read_url - Last9's Read endpoint
  • $levitate_username - Cluster ID
  • $levitate_password - Read token created for the cluster

Ensure RabbitMQ is installed and running on each VM. You should have root or administrative access.

Ensure that rabbitmq_prometheus plugin is configured as per its documentation.

Configure Prometheus Agent to Scrape Metrics

Architecture

prometheus-rabbitmq

Setting up Prometheus Agent

Install Prometheus Agent on a central server that can access all VMs running RabbitMQ. This script can be run on the server:

#!/bin/bash

# Function to determine OS architecture
get_architecture() {
architecture=$(uname -m)
case $architecture in
x86_64)
arch="amd64"
;;
aarch64)
arch="arm64"
;;
arm*)
arch="armv7"
;;
*)
echo "Architecture $architecture is not supported by this script."
exit 1
;;
esac
echo $arch
}

# Define version and architecture
VERSION="2.37.0"
ARCH=$(get_architecture)

# Download and install Prometheus Agent
URL="https://github.com/prometheus/prometheus/releases/download/v$VERSION/prometheus-$VERSION.linux-$ARCH.tar.gz"
wget $URL -O prometheus.tar.gz
tar -xzf prometheus.tar.gz
cd prometheus-$VERSION.linux-$ARCH

# Move executables to your PATH
sudo mv prometheus promtool /usr/local/bin/
sudo mkdir /etc/prometheus
sudo mkdir -p /var/lib/prometheus
sudo mv consoles/ console_libraries/ prometheus.yml /etc/prometheus/

# Create a service file for Prometheus
echo "[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=$USER
Restart=on-failure
ExecStart=/usr/local/bin/prometheus \\
--config.file=/etc/prometheus/prometheus.yml \\
--enable-feature=agent

[Install]
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/prometheus.service

# Reload systemd to pick up the new service and start Prometheus Agent
sudo systemctl daemon-reload
sudo systemctl start prometheus
sudo systemctl enable prometheus

Configure Scrape Targets

Use either ec2_sd_config or file_sd_config to configure scrape targets. The example uses file_sd_config for simplicity.

Create a file targets.json and add the following:

Ensure that the targets are the Private IPs of the RabbitMQ cluster or instances.

[
{
"targets": ["rbmq-vm-1:15692", "rbmq-vm-1:15692"],
"labels": {
"job": "rabbitmq"
}
}
]

Configure Last9 Remote Write Credentials into Prometheus Agent

Add the following remote_write configuration to the prometheus.yml file:

echo "remote_write:
- url: "$remote_write_url"
basic_auth:
username: "$remote_write_username"
password: "$remote_write_password"
write_relabel_configs:
- source_labels: [__name__]
regex: 'rabbitmq_(.*)'" | sudo tee -a /etc/prometheus/prometheus.y

Replace remote_write_* template variables with your Last9 Credentials that can be obtained by following this documentation

Restart Prometheus Agent

Restart Prometheus Agent to apply changes:

sudo systemctl restart prometheus

Verification

  • Check Prometheus Agent' /targets and /graph web interfaces to ensure it's scraping the RabbitMQ metrics
  • Verify that metrics are being received in the remote storage

This script-driven setup automates the deployment and configuration of RabbitMQ monitoring using Prometheus Agent.

Dashboard

Download the latest dashboard from here to visualize the metrics.

rabbitmq-levitate-1 rabbitmq-levitate-2 rabbitmq-levitate-3

Troubleshooting

Please get in touch with us on Discord or Email if you have any questions.