Learn Labs
Foundations

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:

TabUse it for
OverviewMessage rates, queued totals, node health, alarms
Connections / ChannelsWho's connected, from where, with what prefetch, how many unacked
ExchangesBindings; publish a test message
Queues and StreamsDepth, rates, consumers, leader and members; get or purge messages
AdminUsers, 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:

rabbitmqctladministration: users, vhosts, permissions, policies, listing objectsrabbitmq-diagnosticshealth checks and inspection: status, alarms, memory, connectivityrabbitmq-queuesquorum queue and stream operations: membership, rebalancingrabbitmq-pluginsenable / disable pluginsrabbitmq-upgradedrain a node before an upgrade
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 index

Users, permissions, policies

rabbitmqctl add_user billing-svc 'secret'rabbitmqctl set_permissions -p shop billing-svc '^$' '^$' '^orders\.billing$'configure, write, readrabbitmqctl set_user_tags billing-svcno tags = no UI accessrabbitmqctl set_policy -p shop ttl-tmp '^tmp\.' '{"message-ttl":60000}' --apply-to queuesrabbitmqctl list_policies -p shop

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.json

Definitions don't include messages: they describe the topology, not the data in it.

Lab

  1. Run exchanges.py, then list exchanges and bindings for vhost shop with rabbitmqctl.
  2. Publish to orders with order.created.eu using the HTTP API, then get the message from orders.shipping.eu in the UI.
  3. Run check_if_node_is_quorum_critical on each node.
  4. Export the definitions and diff them against config/definitions.json. What did the labs add?

On this page