RabbitMQ Management UI — Complete Guide
In this tutorial, you will learn about RabbitMQ Management UI. We cover key concepts, practical examples, and best practices to help you master this topic.
The RabbitMQ management UI provides a web-based interface for monitoring queues, exchanges, connections, and managing users with real-time metrics.
What You Learn
You will learn how to enable and use the RabbitMQ management plugin, navigate the web UI, monitor key metrics, manage virtual hosts and users, and use the HTTP API for automation.
Why It Matters
The management UI is the first place to go when something goes wrong. It shows queue depths, consumer counts, message rates, and connection status at a glance. Without it, debugging RabbitMQ requires digging through logs and command-line tools.
Real-World Use
DodaTech operations team monitors the RabbitMQ cluster through the management UI. They set up alerts on queue depth and consumer count. When a queue backs up, they see it immediately and investigate.
Enabling the Management Plugin
# Enable the management plugin
sudo rabbitmq-plugins enable rabbitmq_management
# Restart RabbitMQ to apply
sudo systemctl restart rabbitmq-server
# Verify the plugin is running
sudo rabbitmq-plugins list
Expected output:
Configured: E = explicitly enabled; e = implicitly enabled
Status: * = running on rabbit@node1
/ * rabbitmq_management 3.13.0
/ * rabbitmq_management_agent 3.13.0
/ * rabbitmq_web_dispatch 3.13.0
Access the UI at http://localhost:15672 with credentials guest/guest.
Navigating the Management UI
flowchart TB
UI[Management UI] --> Overview
UI --> Connections
UI --> Channels
UI --> Exchanges
UI --> Queues
UI --> Admin
Overview --> Metrics[Node metrics, message rates]
Connections --> Clients[Active connections]
Exchanges --> Routing[Exchange details, bindings]
Queues --> Depth[Queue depth, consumers]
Admin --> Users[User & vhost management]
style UI fill:#f90,color:#fff
Key Metrics in the Overview Tab
import requests
import json
url = "http://localhost:15672/api/overview"
auth = ("guest", "guest")
response = requests.get(url, auth=auth)
data = response.json()
print(f"Cluster: {data['cluster_name']}")
print(f"RabbitMQ version: {data['rabbitmq_version']}")
print(f"Queued messages (ready): {data['queue_totals']['messages_ready']}")
print(f"Queued messages (unacked): {data['queue_totals']['messages_unacknowledged']}")
print(f"Message rates (publish/s): {data['message_stats'].get('publish_details', {}).get('rate', 0):.1f}")
Expected output:
Cluster: rabbit@node1
RabbitMQ version: 3.13.0
Queued messages (ready): 42
Queued messages (unacked): 3
Message rates (publish/s): 156.2
Managing Queues via the API
import requests
import json
base = "http://localhost:15672/api"
auth = ("guest", "guest")
# List all queues
queues = requests.get(f"{base}/queues", auth=auth).json()
print("Queues:")
for q in queues:
print(f" {q['name']}: {q['messages_ready']} ready, {q['messages_unacknowledged']} unacked")
# Create a queue
queue_data = {
"durable": True,
"arguments": {
"x-queue-type": "quorum",
"x-quorum-initial-group-size": 3
}
}
r = requests.put(f"{base}/queues/%2F/api_queue", auth=auth, json=queue_data)
print(f"\nCreate queue status: {r.status_code}")
# Get queue details
q = requests.get(f"{base}/queues/%2F/api_queue", auth=auth).json()
print(f"Queue type: {q.get('arguments', {}).get('x-queue-type', 'classic')}")
print(f"Consumers: {q['consumers']}")
print(f"Messages: {q['messages']}")
Expected output:
Queues:
api_queue: 0 ready, 0 unacked
task_queue: 15 ready, 2 unacked
Create queue status: 201
Queue type: quorum
Consumers: 0
Messages: 0
Managing Users and Permissions
import requests
base = "http://localhost:15672/api"
auth = ("guest", "guest")
# Create a user
user_data = {
"password": "secure_password_123",
"tags": "management"
}
r = requests.put(f"{base}/users/dev_user", auth=auth, json=user_data)
print(f"Create user: {r.status_code}")
# Set permissions (vhost: /, configure: .*, read: .*, write: .*)
perm_data = {
"configure": ".*",
"write": ".*",
"read": ".*"
}
r = requests.put(f"{base}/permissions/%2F/dev_user", auth=auth, json=perm_data)
print(f"Set permissions: {r.status_code}")
# List users
users = requests.get(f"{base}/users", auth=auth).json()
print("\nUsers:")
for u in users:
print(f" {u['name']} (tags: {u['tags']})")
Expected output:
Create user: 201
Set permissions: 201
Users:
guest (tags: administrator)
dev_user (tags: management)
HTTP API Endpoint Reference
| Endpoint | Method | Purpose |
|---|---|---|
/api/overview |
GET | Cluster overview and rates |
/api/queues |
GET | List all queues |
/api/queues/{vhost}/{name} |
GET/PUT/DELETE | Queue details, create, delete |
/api/exchanges |
GET | List all exchanges |
/api/connections |
GET | Active connections |
/api/users |
GET/PUT | User management |
/api/healthchecks/node |
GET | Node health check |
Common Mistakes
1. Leaving Default Credentials
Change the default guest/guest password. The guest user can only connect from localhost by default, but it is still a security risk.
2. Exposing the Management UI Publicly
Do not expose port 15672 to the internet. Use a VPN or SSH tunnel. The API provides full control of the broker.
3. Ignoring the Warning Banners
The UI shows warnings for disk space, memory, and file descriptor usage. These alerts prevent broker crashes. Address them immediately.
4. Not Using Virtual Hosts
Virtual hosts isolate environments. Create separate vhosts for development, staging, and production. Each vhost has independent queues and permissions.
5. Relying Only on the UI
Automate monitoring with the HTTP API. The UI is great for ad-hoc debugging but does not scale for alerting. Use Prometheus or a monitoring tool.
Practice Questions
1. What port does the management UI run on?
15672 by default. The management TLS port is 15671.
2. How do you enable the management plugin?
Run sudo rabbitmq-plugins enable rabbitmq_management and restart RabbitMQ.
3. What is a virtual host used for?
Virtual hosts (vhosts) provide logical isolation. Queues, exchanges, and users in one vhost cannot access resources in another.
4. How do you access the management API?
Send HTTP requests to port 15672 with basic authentication. The API is at /api/ with endpoints for all management operations.
Challenge
Write a Python script that monitors all queues, alerts if any queue has more than 1000 ready messages for more than 60 seconds, and sends a notification to a Webhook URL.
FAQ
Mini Project: Cluster Health Dashboard
import requests
import json
import time
import sys
class RabbitMQDashboard:
def __init__(self, host='localhost', port=15672, user='guest', password='guest'):
self.base = f"http://{host}:{port}/api"
self.auth = (user, password)
def get_overview(self):
return requests.get(f"{self.base}/overview", auth=self.auth).json()
def get_queues(self):
return requests.get(f"{self.base}/queues", auth=self.auth).json()
def get_nodes(self):
return requests.get(f"{self.base}/nodes", auth=self.auth).json()
def print_dashboard(self):
overview = self.get_overview()
queues = self.get_queues()
nodes = self.get_nodes()
print(f"Cluster: {overview['cluster_name']}")
print(f"Version: {overview['rabbitmq_version']}")
print(f"Nodes: {len(nodes)}")
print()
for node in nodes:
print(f"Node {node['name']}:")
print(f" Memory: {node['mem_used']/1024/1024:.0f} MB")
print(f" Disk free: {node['disk_free']/1024/1024/1024:.1f} GB")
print(f" FD used: {node['fd_used']}/{node['fd_total']}")
print("\nQueues with messages:")
for q in queues:
if q['messages'] > 0:
print(f" {q['name']}: {q['messages_ready']} ready, "
f"{q['messages_unacknowledged']} unacked, "
f"{q['consumers']} consumers")
if q['messages_ready'] > 1000:
print(f" *** ALERT: {q['name']} has {q['messages_ready']} messages!")
if __name__ == '__main__':
dash = RabbitMQDashboard()
try:
while True:
os.system('clear')
dash.print_dashboard()
time.sleep(5)
except KeyboardInterrupt:
print("\nMonitoring stopped")
Expected output:
Cluster: rabbit@node1
Version: 3.13.0
Nodes: 3
Node rabbit@node1:
Memory: 256 MB
Disk free: 45.3 GB
FD used: 64/1048576
Queues with messages:
task_queue: 15 ready, 2 unacked, 3 consumers
What's Next
Now that you understand the management UI, explore RabbitMQ with Python for building applications, then learn about RabbitMQ security for securing your broker.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro