Management Tools
The UI, rabbitmqctl, rabbitmq-diagnostics, the HTTP API, and definitions
RabbitMQ has four ways in: a web UI for looking, three CLI tools for doing, an HTTP API for automating, and definitions files for keeping topology in git.
The management UI
http://localhost:15672 (admin / admin123). The tabs that matter:
| Tab | Use it for |
|---|---|
| Overview | Message rates, queued totals, node health, alarms |
| Connections / Channels | Who's connected, from where, with what prefetch, how many unacked |
| Exchanges | Bindings; publish a test message |
| Queues and Streams | Depth, rates, consumers, leader and members; get or purge messages |
| Admin | Users, vhosts, permissions, policies, limits |
The UI's numbers come from the same metrics as Prometheus, sampled every few seconds. For long-term graphs and alerts, use Prometheus.
The CLI tools
They run inside each node container:
R() { docker exec rabbit-1 "$@"; }
R rabbitmqctl -q list_queues -p shop name type messages consumers leader members
R rabbitmqctl -q list_exchanges -p shop name type
R rabbitmqctl -q list_bindings -p shop source_name routing_key destination_name
R rabbitmqctl -q list_connections user peer_host channels state
R rabbitmqctl -q list_consumers -p shop queue_name prefetch_count ack_required
R rabbitmq-diagnostics status # versions, memory breakdown, listeners, alarms
R rabbitmq-diagnostics -q alarms
R rabbitmq-diagnostics -q check_port_connectivity # what the compose healthcheck runs
R rabbitmq-queues quorum_status orders.billing --vhost shop # each replica's Raft state and log indexrabbitmq-diagnostics has a whole family of health checks:
check_running, check_local_alarms, check_port_connectivity,
check_virtual_hosts, check_if_node_is_quorum_critical. The last one
answers "would shutting this node down make any quorum queue lose its
majority?" Run it before every planned restart.
Users, permissions, policies
Permissions are three regexes over resource names: configure (declare and delete), write (publish to an exchange, bind), and read (consume, and bind from an exchange). More in Security.
Policies apply settings (TTL, max length, dead-lettering, queue leader placement) to every queue matching a pattern, and can be changed at runtime. Queue arguments are fixed at declaration. Prefer policies for anything you might want to tune later.
The HTTP API
Everything in the UI is the HTTP API underneath:
curl -s -u admin:admin123 localhost:15672/api/overview | jq '.rabbitmq_version, .queue_totals'
curl -s -u admin:admin123 localhost:15672/api/queues/shop | jq '.[] | {name, type, messages}'
curl -s -u admin:admin123 localhost:15672/api/nodes | jq '.[] | {name, running, mem_used, mem_limit}'
# publish a test message
curl -s -u admin:admin123 -X POST localhost:15672/api/exchanges/shop/orders/publish \
-d '{"properties":{},"routing_key":"order.created.eu","payload":"hello","payload_encoding":"string"}'Definitions
A definitions file is a JSON snapshot of users, vhosts, permissions,
exchanges, queues, bindings, and policies. This cluster loads
config/definitions.json at boot. Export the live state to compare or back
it up:
docker exec rabbit-1 rabbitmqctl export_definitions /tmp/defs.json
docker exec rabbit-1 cat /tmp/defs.json | jq '.queues[].name'
docker exec rabbit-1 rabbitmqctl import_definitions /tmp/defs.jsonDefinitions don't include messages: they describe the topology, not the data in it.
Lab
- Run
exchanges.py, then list exchanges and bindings for vhostshopwithrabbitmqctl. - Publish to
orderswithorder.created.euusing the HTTP API, thengetthe message fromorders.shipping.euin the UI. - Run
check_if_node_is_quorum_criticalon each node. - Export the definitions and diff them against
config/definitions.json. What did the labs add?