Cheat Sheet

Kafka & RabbitMQ CLI

Every flag you reach for when debugging a queue or a topic: Kafka 4.0 tools with --bootstrap-server only, RabbitMQ operator tools, rabbitmqadmin v2 and the matching aws sqs commands.

Kafka 4.0
Source checked
RabbitMQ
Man pages
AWS CLI 2
Help verified
Index ยท Spring ยท SQL ยท Git ยท Docker/kubectl ยท Kafka/Rabbit CLI ยท Redis ยท Big-O
01
Chapter 1 - Conventions

Read This First

Kafka tools live in the bin/ folder of the Kafka distribution as kafka-*.sh (Windows: bin/windows/*.bat). In Kafka 4.0 the tools talk to brokers only through --bootstrap-server host:port. The old --zookeeper option is gone with ZooKeeper, and --broker-list is not an option of the 4.0 console producer (checked in the 4.0 source). For client security settings add --command-config file.properties (admin tools) or --consumer.config / --producer.config (console clients).

Variable used belowMeaning
$BSYour bootstrap servers, for example localhost:9092 or broker1:9092,broker2:9092
$TTopic name
$GConsumer group id
Safe habit

Tools that change things (--alter, --delete, --execute) deserve a dry run or a describe first. kafka-consumer-groups.sh --reset-offsets is a dry run unless you add --execute.

02
Chapter 2 - kafka-topics.sh

Topics

Flags checked against the Kafka 4.0 TopicCommand source.

Command or flagWhat it doesGotcha
--bootstrap-server $BS --listList topics--exclude-internal hides __consumer_offsets and friends
--create --topic $T --partitions 6 --replication-factor 3Create a topicReplication factor cannot exceed the broker count; --if-not-exists makes it idempotent
--create ... --config retention.ms=604800000Set topic configs at creationRepeat --config per key
--describe --topic $TPartitions, leaders, replicas, ISRWithout --topic it describes every topic; --topic-id selects by id
--describe --under-replicated-partitionsOnly partitions whose ISR is smaller than the replica setNon-empty output = something is lagging or down
--describe --unavailable-partitionsPartitions with no leaderClients cannot produce or consume these
--describe --under-min-isr-partitionsISR below the min.insync.replicas settingWith acks=all producers get NotEnoughReplicas errors
--describe --at-min-isr-partitionsISR exactly at the minimumOne more failure stops writes: a warning sign
--describe --topics-with-overridesTopics that have config overridesQuick audit of non-default settings
--alter --topic $T --partitions 12Increase the partition countCannot decrease; key-to-partition mapping changes for new records
--delete --topic $TDelete a topicNeeds delete.topic.enable on the cluster (default true); data is gone
--command-config client.propertiesClient properties file (SASL, TLS)Needed on secured clusters, otherwise timeouts
--config / --delete-config on --alterAlter topic configsThe --delete-config option on this tool is deprecated since 4.0: use kafka-configs.sh
03
Chapter 3 - Console producer and consumer

Producing and Consuming from the Shell

For smoke tests and debugging, not for load.

Command or flagWhat it doesGotcha
kafka-console-producer.sh --bootstrap-server $BS --topic $TSend each typed line as a recordCtrl-D ends it; value only, no key by default
--property parse.key=true --property key.separator=:Treat key:value lines as key and valueA line without the separator fails unless ignore.error=true
--property parse.headers=trueParse record headers from the lineFormat is controlled by headers.delimiter and related properties
--producer-property acks=allSet any producer configRepeatable; or load a file with --producer.config
--compression-codec gzipCompress batches--sync sends one record at a time and is slow
kafka-console-consumer.sh --bootstrap-server $BS --topic $T --from-beginningRead from the earliest offsetOnly applies when the group has no committed offsets
--group $GUse a named group (commits offsets)Without it the tool makes a random group each run, which pollutes the group list
--max-messages 10Exit after N recordsGood for scripts
--partition 2 --offset 100Read one partition from an offset--offset accepts a number, earliest or latest, and needs --partition
--timeout-ms 5000Exit if no record arrives for this longOtherwise it runs until you stop it
--property print.key=trueAlso print the keyOthers: print.timestamp, print.offset, print.partition, print.headers, print.value, key.separator
--isolation-level read_committedHide records of open or aborted transactionsDefault is read_uncommitted
--key-deserializer / --value-deserializerPick a deserializer classDefault prints bytes as strings; binary data looks garbled
--consumer-property k=v, --consumer.config fSet any consumer configProperty options override the file
--include "orders.*"Subscribe by regexUse instead of --topic
04
Chapter 4 - kafka-consumer-groups.sh

Groups, Lag and Offset Resets

Flags checked against the Kafka 4.0 ConsumerGroupCommandOptions source.

Command or flagWhat it doesGotcha
--bootstrap-server $BS --listList group ids--state (and --type) filter the list
--describe --group $GPer partition: current offset, log end offset, LAG, consumer id, hostA - consumer id means the partition has no active owner
--describe --all-groupsDescribe every groupCan be heavy on large clusters
--describe --group $G --members [--verbose]Members and, with verbose, their assignmentsShows rebalance victims quickly
--describe --group $G --stateGroup state and coordinatorStates: Stable, PreparingRebalance, Empty, Dead and others
--describe --group $G --offsetsOffsets only (the default view)Lag is only an estimate at the moment of the call
--reset-offsets --group $G --topic $T --to-earliestPlan a reset to the beginningDry run by default; the group must have no active members
--to-latest / --to-offset N / --shift-by -100Other reset targets--shift-by takes a negative number to rewind
--to-datetime 2026-10-31T00:00:00.000Reset to the first offset at or after a timeFormat YYYY-MM-DDTHH:mm:SS.sss
--by-duration PT1HReset to a point in the pastISO-8601 duration
--to-currentReset to the current committed offsetMostly useful with --topic scoping
--all-topicsApply the reset to every topic the group consumedUse --topic t:0,1,2 to select partitions
--execute / --dry-run / --exportApply the reset / show only / write a CSV--from-file applies a CSV back; always dry-run first
--delete --group $GDelete a groupFails if the group still has members
--delete-offsets --group $G --topic $TForget a group's offsets for a topicGroup must not be consuming that topic
05
Chapter 5 - Configs, offsets, logs, perf

kafka-configs, kafka-get-offsets, kafka-dump-log, perf tests

Inspect and tune without touching application code.

Command or flagWhat it doesGotcha
kafka-configs.sh --bootstrap-server $BS --entity-type topics --entity-name $T --describeShow topic overrides--all also lists static and default configs
... --alter --add-config retention.ms=86400000Set a topic configSeveral keys: --add-config k1=v1,k2=v2; values with commas go in square brackets
... --alter --delete-config retention.msRemove an override (back to the default)Applies to topics, brokers, clients, users and more
--entity-type brokers --entity-name 1 --alter --add-config ...Dynamic per-broker config--entity-default sets it for all brokers
--entity-type clients / usersClient or user quotasNeeds the right entity combination
kafka-get-offsets.sh --bootstrap-server $BS --topic $TLatest offset per partitionDefault --time is latest
--time -2 (or earliest)Earliest offsetsAlso -3 / max-timestamp, -4 / earliest-local, -5 / latest-tiered, or a timestamp in ms
--topic-partitions "t1:0,t2:1-3"Select partitions with a patternUse either --topic or --topic-partitions
kafka-dump-log.sh --files <segment>.log --print-data-logRead a segment file, including record contentsRun on a broker data directory; do not point at a live active segment without care
--deep-iteration, --max-message-size, --verify-index-onlyLook inside compressed batches; raise size; check index filesDecoders exist for internal topics: --offsets-decoder, --transaction-log-decoder, --cluster-metadata-decoder
kafka-producer-perf-test.sh --topic $T --num-records 100000 --record-size 1024 --throughput -1 --producer-props bootstrap.servers=$BS acks=allProducer load test--throughput -1 means no throttle; also --payload-file, --print-metrics, --transactional-id; use a test topic
kafka-consumer-perf-test.shConsumer load testExists in 4.0; see its --help for flags
06
Chapter 6 - Other Kafka tools

Cluster, Reassignment, Quorum

Present in the 4.0 bin/ folder (checked in the repository). Run each with --help for its flags.

ToolUseGotcha
kafka-metadata-quorum.shDescribe the KRaft controller quorum (describe --status, --replication)Can connect with --bootstrap-server or --bootstrap-controller
kafka-storage.shFormat storage and generate a cluster id for KRaftformat must run before the first start; formatting an existing directory is destructive
kafka-features.shDescribe and upgrade feature levelsFinalizing a level may block downgrades
kafka-reassign-partitions.shMove replicas between brokersThrottle the move to protect traffic; verify before and after
kafka-leader-election.shTrigger preferred or unclean leader electionUnclean election can lose data
kafka-log-dirs.shDescribe log directories and sizes per brokerGood for disk questions
kafka-delete-records.shDelete records before an offsetTakes a JSON file; cannot be undone
kafka-acls.shManage ACLsNeed an authorizer configured
kafka-broker-api-versions.shShow API versions a broker supportsFirst step for client compatibility questions
kafka-transactions.shInspect and abort hanging transactionsUse only after understanding the producer state
kafka-groups.shList groups of all types (listed in the 4.0 bin/)Check --help; consumer group tool remains the main one
07
Chapter 7 - Worked sequence

Find Lag, Peek, Reset

Stop the consuming application before the --execute step; a group with active members cannot be reset.

A typical diagnosis sequence (commands only; output varies, so none is shown)
$ BS=localhost:9092 $ bin/kafka-topics.sh --bootstrap-server $BS --describe --under-replicated-partitions $ bin/kafka-consumer-groups.sh --bootstrap-server $BS --describe --group orders-service $ bin/kafka-get-offsets.sh --bootstrap-server $BS --topic orders --time latest $ bin/kafka-console-consumer.sh --bootstrap-server $BS --topic orders --partition 3 --offset 1200 \ --max-messages 5 --property print.key=true --property print.offset=true --property print.timestamp=true $ bin/kafka-consumer-groups.sh --bootstrap-server $BS --group orders-service --topic orders \ --reset-offsets --to-datetime 2026-10-31T09:00:00.000 # dry run $ bin/kafka-consumer-groups.sh --bootstrap-server $BS --group orders-service --topic orders \ --reset-offsets --to-datetime 2026-10-31T09:00:00.000 --execute
08
Chapter 8 - RabbitMQ: rabbitmqctl

Operator Commands

Command names checked against the rabbitmqctl man page (rabbitmqctl.8 in the RabbitMQ server repository, main branch). Use -p vhost for a virtual host and -n rabbit@host for another node; rabbitmqctl help lists everything.

Command or flagWhat it doesGotcha
rabbitmqctl statusNode status: versions, memory, alarms, listenersUse rabbitmq-diagnostics status too
rabbitmqctl cluster_statusCluster members, disk and RAM nodes, partitions, alarmsLook for "Network Partitions"
rabbitmqctl list_queues name messages_ready messages_unacknowledged consumers typeQueue table with the columns you pickAdd -p vhost; counts can lag a few seconds; --offline and --online filter by queue availability
rabbitmqctl list_exchanges name type, list_bindingsTopologyBindings show source, destination and routing key
rabbitmqctl list_consumersConsumers per queueZero consumers on a growing queue = stuck application
rabbitmqctl list_connections name state, list_channelsClient connections and channelsMany channels per connection can be a leak
rabbitmqctl close_connection <pid> "reason"Close one connectionUse the pid from list_connections
rabbitmqctl purge_queue qDelete all ready messages in a queueUnacked messages stay
rabbitmqctl delete_queue q [--if-empty]Delete a queue--if-empty / --if-unused guard against surprises
rabbitmqctl add_user u p / list_users / change_password / delete_userUser managementThe password appears in shell history; prefer a prompt or hash_password flows
rabbitmqctl set_user_tags u administratorManagement UI rolesTags are not permissions
rabbitmqctl add_vhost v / list_vhosts / delete_vhost vVirtual hostsDeleting a vhost deletes its queues and messages
rabbitmqctl set_permissions -p v u ".*" ".*" ".*"Configure, write, read regexes for a user on a vhostOrder is configure, write, read; empty string = nothing
rabbitmqctl set_policy -p v name "^orders-" '{"max-length":10000}' --apply-to queuesApply optional arguments to matching queueslist_policies shows them; check --priority when several patterns match the same queue
rabbitmqctl stop_app / start_app / resetStop or start the application, wipe node statereset removes all data on the node; used when changing cluster membership
rabbitmqctl join_cluster rabbit@seedJoin this node to a clusterRun stop_app first and start_app after
rabbitmqctl forget_cluster_node rabbit@deadRemove a dead node from the clusterOnly for nodes that will not come back
rabbitmqctl enable_feature_flag all, list_feature_flagsFeature flagsEnable all flags before an upgrade to the next major version
rabbitmqctl set_vm_memory_high_watermark 0.6Change the memory alarm threshold at runtimeResets on restart; set it in the config file too
rabbitmqctl shutdown, await_startup, waitStop the node and the Erlang VM; wait for startupPreferred in scripts over killing the process
09
Chapter 9 - RabbitMQ: diagnostics, queues, plugins

Health and Quorum Queue Tools

Names checked against rabbitmq-diagnostics.8 and rabbitmq-queues.8 (RabbitMQ server repository, main).

Command or flagWhat it doesGotcha
rabbitmq-diagnostics statusRich node statusFirst command when someone says "RabbitMQ is slow"
rabbitmq-diagnostics pingIs the node reachable by CLI toolsChecks CLI to node connectivity only
rabbitmq-diagnostics check_runningIs the application runningExit code is non-zero if not, good for probes
rabbitmq-diagnostics check_local_alarms, check_alarmsMemory and disk alarms (this node / cluster)An alarm blocks publishers
rabbitmq-diagnostics check_port_connectivity, check_port_listener 5672Are the listener ports openExpects --longnames on long-name nodes
rabbitmq-diagnostics memory_breakdown --unit MBWhere the memory isLarge binary or queue_procs points at message backlog
rabbitmq-diagnostics listenersProtocols and portsConfirms TLS and plugin listeners
rabbitmq-diagnostics cluster_status, environment, reportCluster view, runtime environment, a long support reportreport output is what support asks for
rabbitmq-diagnostics log_tail -N 100Last log lines from the nodeWorks remotely via -n
rabbitmq-diagnostics maybe_stuckFind possibly stuck Erlang processesDiagnostic, not proof
rabbitmq-queues quorum_status q --vhost vRaft members, leader and log state of a quorum queueMissing members mean reduced fault tolerance
rabbitmq-queues add_member q rabbit@n --vhost v, delete_memberChange quorum queue replicasOdd member counts are preferred
rabbitmq-queues rebalance quorum, transfer_leadershipSpread or move leadersLeaders concentrate on one node after restarts
rabbitmq-queues check_if_node_is_quorum_criticalWould stopping this node break a quorumRun before maintenance, also exposed as rabbitmq-diagnostics check_if_node_is_quorum_critical
rabbitmq-plugins enable rabbitmq_managementEnable a pluginTakes effect on a running node without a restart for most plugins
10
Chapter 10 - RabbitMQ: rabbitmqadmin v2

The HTTP API CLI

There are two generations. rabbitmqadmin v2 (the rabbitmqadmin-ng project) is a standalone native binary and is what the current RabbitMQ documentation describes. v1 was a Python script served by the management plugin. The syntax differs: v2 uses named options (--name "q"), v1 used name="q" arguments. It needs the rabbitmq_management plugin (HTTP API). Syntax below is from the RabbitMQ documentation page "rabbitmqadmin v2".

Command or flagWhat it doesGotcha
rabbitmqadmin help, rabbitmqadmin queues help declareCommand groups and per-command helpGroup names include queues, exchanges, bindings, vhosts, users, permissions, policies, connections, channels, consumers, definitions, health_check
rabbitmqadmin show overviewCluster overview and ratesUse --non-interactive in scripts
rabbitmqadmin queues list, --vhost "v" queues listList queues--vhost goes before the group
rabbitmqadmin --vhost "v" queues declare --name "q" --type "quorum" --durable trueCreate a queueTypes: classic, quorum, stream
rabbitmqadmin --vhost "v" queues show --name "q" --columns "name,type,messages,consumers"Show one queue--columns limits the output
rabbitmqadmin --vhost "v" queues purge --name "q", queues delete --name "q" --idempotentlyPurge / delete--idempotently makes delete not fail if absent
rabbitmqadmin --vhost "v" exchanges declare --name "x" --type "topic" --durable trueCreate an exchangeTypes include direct, fanout, topic, headers
rabbitmqadmin --vhost "v" bindings declare --source "x" --destination-type "queue" --destination "q" --routing-key "orders.created"BindSource is an exchange; destination a queue or exchange
rabbitmqadmin vhosts declare --name "v" --default-queue-type "quorum"Create a vhostvhosts delete --name "v"; vhosts delete_multiple --name-pattern "^test-" --dry-run previews bulk deletion
rabbitmqadmin users declare --name "u" --password "p" --tags "monitoring", permissions declare ...Users and permissions--password-hash avoids plain text; permissions take --configure, --read, --write regexes
rabbitmqadmin definitions export --file defs.json, definitions import --file defs.jsonBack up or restore topology--transformations exclude_users,exclude_permissions removes parts on export
rabbitmqadmin health_check local_alarmsHealth checks over the HTTP APIOthers: cluster_wide_alarms, node_is_quorum_critical, port_listener --port 5672
rabbitmqadmin rebalance queuesRebalance queue leaders across nodesOptionally scoped with --vhost
rabbitmqadmin connections close --name "..."Close a connectionName as printed by connections list
11
Chapter 11 - AWS SQS CLI

The aws sqs Commands

Subcommands and option names verified with aws sqs help on AWS CLI 2.32.25. SQS is the queue counterpart of the RabbitMQ commands above. Queue URLs look like https://sqs.REGION.amazonaws.com/ACCOUNT/NAME.

Command or flagWhat it doesGotcha
aws sqs create-queue --queue-name q --attributes VisibilityTimeout=60Create a queueFIFO queue names must end in .fifo and need FifoQueue=true
aws sqs list-queues [--queue-name-prefix p]List queuesReturns URLs
aws sqs get-queue-url --queue-name qResolve name to URLAdd --queue-owner-aws-account-id for cross-account
aws sqs get-queue-attributes --queue-url U --attribute-names AllSettings and approximate countsApproximateNumberOfMessages, ...NotVisible, ...Delayed are approximate
aws sqs set-queue-attributes --queue-url U --attributes file://a.jsonChange visibility timeout, retention, redrive policy, ...RedrivePolicy is a JSON string inside the JSON
aws sqs send-message --queue-url U --message-body "hi" [--delay-seconds 10]Send a messageFIFO needs --message-group-id (and a dedup id unless content-based dedup is on)
aws sqs send-message-batch --queue-url U --entries file://e.jsonSend up to ten messagesPer-entry failures are reported in the response, not as an error
aws sqs receive-message --queue-url U --max-number-of-messages 10 --wait-time-seconds 20Receive messages with long pollingWithout a wait time you short-poll and may get an empty reply even when messages exist
... --visibility-timeout 60 --attribute-names All --message-attribute-names AllPer-call visibility timeout and attributesMessages become visible again after the timeout unless deleted
aws sqs delete-message --queue-url U --receipt-handle HAcknowledge (delete) a received messageReceipt handle comes from receive-message and changes per receive
aws sqs change-message-visibility --queue-url U --receipt-handle H --visibility-timeout 120Extend or shorten processing timechange-message-visibility-batch for many
aws sqs purge-queue --queue-url UDelete all messagesAlso deletes in-flight messages; the deletion takes up to 60 seconds and cannot be undone
aws sqs list-dead-letter-source-queues --queue-url DLQ_URLWhich queues use this as DLQTakes the DLQ URL
aws sqs start-message-move-task --source-arn DLQ_ARN [--destination-arn Q_ARN]Redrive from a DLQAlso --max-number-of-messages-per-second; see list-message-move-tasks and cancel-message-move-task
aws sqs tag-queue, list-queue-tags, add-permission, remove-permissionTags and queue policy statementsCheck the queue policy when cross-account access fails
12
Chapter 12 - Common mistakes

Messaging CLI Mistakes

โš  The ones that cost real time
  • **--broker-list or --zookeeper on Kafka 4.0.** Removed; use --bootstrap-server.
  • **Running the console consumer without --group.** Each run creates a throwaway group.
  • Resetting offsets while the app is running. The reset is refused for active groups, or the app overwrites it.
  • **Forgetting --execute (or adding it too early).** --reset-offsets is a dry run by default.
  • Decreasing partitions. Not possible; create a new topic and migrate.
  • **rabbitmqctl reset on a node you wanted to keep.** It wipes the node.
  • **Mixing v1 and v2 rabbitmqadmin syntax.** name="q" is v1, --name "q" is v2.
  • SQS short polling in scripts. Use --wait-time-seconds 20.
  • **Treating ApproximateNumberOfMessages as exact.** It is eventually consistent.
  • Purging a production queue to "fix" a backlog. Messages are gone; move them to a DLQ or fix the consumer.
13
Chapter 13 - Go deeper

Long-form pages and what was checked

TopicPage
Kafka internals: partitions, replication, offsetsKafka Architecture
Producer and consumer behaviour behind the flagsKafka Producers & Consumers
Spring KafkaKafka with Spring
RabbitMQ concepts: exchanges, queues, quorum queuesRabbitMQ
SQS, SNS, MSK, Amazon MQAWS Messaging
Lag, DLQs, monitoringReliability & Operations
Version note

Checked on 2026-10-31. Kafka 4.0: option names of kafka-topics, kafka-console-consumer, kafka-console-producer (including parse.key, key.separator, print.* properties), kafka-consumer-groups (including --dry-run as the default for reset), kafka-get-offsets (default --time latest), kafka-configs, kafka-dump-log and kafka-producer-perf-test against the 4.0 branch of the Apache Kafka source, and the tool list against the 4.0 bin/ folder. RabbitMQ: rabbitmqctl, rabbitmq-diagnostics and rabbitmq-queues command names against the man pages in the RabbitMQ server repository (main) and rabbitmqadmin v2 syntax against the RabbitMQ documentation page for rabbitmqadmin v2 (its command-group list has no publish or get-message commands, so none are shown). AWS: subcommands and option names against aws sqs help on AWS CLI 2.32.25 run locally. Not run: no Kafka, RabbitMQ or AWS account was used, so behaviour notes (for example RabbitMQ side effects such as reset wiping a node) come from the vendor documentation and experience, not from a run here.