Skip to content
Tutorials Center
My learning

Topics

Lesson 30 of 37 ยท Operations and Monitoring

Management UI, HTTP API and CLI Tools

Learn to operate RabbitMQ with the management plugin, its HTTP API and the CLI tools rabbitmqctl, rabbitmq-diagnostics, rabbitmq-queues and rabbitmq-plugins, with runnable parsing examples.

A message broker that you cannot inspect is a risk. RabbitMQ gives you three ways to look inside and change things: the management UI (a web page), the HTTP API behind it, and a family of command-line tools. In day-to-day operations you mix them: the UI for a quick look, the CLI for scripts and rolling maintenance, the API for dashboards and automation.

RabbitMQ is not installed on this page, so every shell command and URL below is read-only. The runnable blocks are plain Python stand-ins that parse realistic API and CLI output so you learn how to automate checks; the data is sample data, not from a live broker.

Enabling the management plugin

The plugin is shipped with RabbitMQ but disabled by default:

Text
rabbitmq-plugins enable rabbitmq_management
rabbitmq-plugins list

The UI then listens on http://localhost:15672 (HTTPS on 15671 with TLS configured). Log in as guest with password guest, which only works from localhost; for any real use create your own user and delete or restrict guest (see Security: Users, Virtual Hosts and TLS). Docker users usually run the image rabbitmq:4-management and publish ports 5672 and 15672.

A tour of the UI

  • Overview: message rates (publish, deliver, ack), queued totals (ready, unacked), global counts of connections, channels, exchanges, queues and consumers, node health, ports and import/export of definitions.
  • Connections and Channels: who is connected, from where, how much they send, and whether they are blocked or in flow control.
  • Exchanges and Queues and Streams: details, bindings, arguments, policies, and tools to publish a test message, get messages (peek with requeue) and purge a queue.
  • Admin: users, virtual hosts, permissions, policies, limits, feature flags and cluster settings.

What to look at first

Ready Backlog waiting for consumers.
Unacked Delivered but not yet acked.
Consumers Zero means nobody is draining.
Rates Publish versus ack per second.

Growing ready plus flat rates means too few workers.

1 / 2

The "Get messages" button in the UI is for debugging: with ack mode "Nack message requeue true" it looks at messages without removing them, but it can still change the redelivered flag and ordering, so do not use it casually on production queues.

The HTTP API

Everything the UI shows comes from a JSON API under /api, protected with HTTP basic auth:

Text
curl -u admin:secret http://localhost:15672/api/overview
curl -u admin:secret http://localhost:15672/api/queues/%2F          # vhost "/" is %2F
curl -u admin:secret http://localhost:15672/api/queues/%2F/orders
curl -u admin:secret http://localhost:15672/api/nodes
curl -u admin:secret http://localhost:15672/api/health/checks/alarms
curl -u admin:secret -X PUT -H "content-type: application/json" \
     -d '{"type":"quorum","durable":true}' \
     http://localhost:15672/api/queues/%2F/payments

A vhost named / must be written as %2F. Useful endpoints include /api/connections, /api/consumers, /api/bindings, /api/policies, /api/definitions (export/import everything) and the health/checks/* family, which returns HTTP 200 when a check passes and 503 otherwise, a good fit for load balancer probes and Kubernetes readiness checks.

Be careful with polling: the management API aggregates statistics, which is expensive on brokers with thousands of queues. For continuous monitoring prefer the Prometheus endpoint in Monitoring and Prometheus.

Python Stand-in: find trouble in /api/queues output

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The command-line tools

RabbitMQ ships several CLI tools. They talk to a running node using the Erlang cookie, so run them as the same OS user as the broker (or with the same cookie).

Tool Purpose Examples
rabbitmqctl General administration status, list_queues, add_user, set_permissions, set_policy, stop_app
rabbitmq-diagnostics Read-only checks and diagnostics check_running, check_local_alarms, memory_breakdown, observer
rabbitmq-plugins Manage plugins enable, disable, list
rabbitmq-queues Queue and replica operations quorum_status, add_member, rebalance
rabbitmq-streams Stream operations stream_status, add_replica
rabbitmq-upgrade Rolling upgrade helpers drain, revive

Commands you will use constantly:

Text
rabbitmqctl list_queues name type messages_ready messages_unacknowledged consumers
rabbitmqctl list_connections user peer_host state
rabbitmqctl list_consumers
rabbitmqctl list_exchanges name type durable
rabbitmqctl list_bindings
rabbitmqctl purge_queue orders
rabbitmqctl export_definitions defs.json
rabbitmq-diagnostics check_running
rabbitmq-diagnostics check_port_connectivity
rabbitmq-diagnostics ping

Add --formatter json to get machine-readable output, and -n rabbit@node2 to target another node. Table output is tab-separated with a header line.

Python Stand-in: parse rabbitmqctl list_queues output

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Definitions, policies and rabbitmqadmin

Definitions are a JSON snapshot of the broker's metadata (vhosts, users, queues, exchanges, bindings, policies). Export them before upgrades, store them in version control and load them at startup with load_definitions = /etc/rabbitmq/definitions.json in rabbitmq.conf. Importing definitions is how teams bootstrap development and test brokers.

Policies set queue and exchange behavior by pattern, without changing application code: TTLs, length limits, dead letter exchanges, queue types, federation and shovel settings. A policy applies to all entities in a vhost whose names match a regular expression, and only one policy applies to an entity (the highest priority one), so combine settings in a single policy.

Text
rabbitmqctl set_policy -p shop orders-limits "^orders" \
  '{"dead-letter-exchange":"orders.dlx","max-length":100000,"overflow":"reject-publish"}' \
  --priority 10 --apply-to queues

rabbitmqadmin (v2, a separate download) offers friendlier commands on top of the HTTP API: rabbitmqadmin declare queue --name payments --type quorum, list queues, publish, get. Use it for scripts that need to declare topology outside application code.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which URL path is used for the default virtual host in the HTTP API?

    The default vhost is named / and must be URL-encoded as %2F.
  2. 2. Which tool performs read-only health checks like check_running and memory_breakdown?

    rabbitmq-diagnostics holds the read-only diagnostic and check commands.
  3. 3. Why is it risky to poll /api/queues every second on a broker with thousands of queues?

    Use the Prometheus endpoint for continuous metrics; keep the management API for occasional queries and checks.
  4. 4. How many policies apply to a single queue at one time?

    Only one policy applies, so put all settings for a group of queues into one policy.

Summary

  • Enable rabbitmq_management for the UI (15672) and the JSON HTTP API; encode the default vhost as %2F.
  • Use rabbitmqctl, rabbitmq-diagnostics, rabbitmq-queues and friends for administration and scripted checks.
  • Export definitions and keep them in version control; use policies to change queue behavior without redeploying code.
  • Keep the management API for light-weight queries; use Prometheus for metrics.

Next: Monitoring and Prometheus