Tool cheatsheet
Apache Kafka 4 Cheatsheet
Start a broker, manage topics, produce and consume messages, and inspect consumer groups. Run these from the Kafka install folder.
Start a broker (KRaft)
- Generate a cluster ID — Create a random ID for a new cluster.
- Format the log directories — Prepare storage for a single-node cluster. Do this once per new cluster.
- Start the broker — Start Kafka with the default configuration.
- Check the broker is reachable — List the APIs and versions the broker supports.
- Check the controller quorum — Show the KRaft quorum status and who the leader is.
Topics
- Create a topic — Create a topic with three partitions.
- List topics — Show the topics in the cluster.
- Describe a topic — Show partitions, leaders and replicas.
- Add partitions — Increase a topic's partition count. You can't reduce it.
- Delete a topic — Delete a topic and its data.
- Set a topic's retention — Keep messages for 7 days.
- See the latest offsets — Print the end offset of each partition.
Producing and consuming
- Send messages from the terminal — Type one message per line. Press Ctrl+C to stop.
- Send keyed messages — Type key:value pairs. Messages with the same key go to the same partition.
- Read messages from the start — Read a topic from the earliest offset.
- Show keys and timestamps — Print each message's key and timestamp too.
- Consume as part of a group — Join a consumer group so the group's offsets are saved.
Consumer groups
- List consumer groups — Show all consumer groups in the cluster.
- Check consumer lag — Show each partition's current offset, end offset and lag for a group.
- Preview an offset reset — Show what resetting to the earliest offset would do, without changing anything. The group must have no active consumers.
- Reset offsets — Move the group back to the earliest offset so it reprocesses messages.
- Delete a consumer group — Delete a group that has no active members.
Performance and debugging
- Test producer throughput — Send 100,000 records of 100 bytes as fast as possible.
- Test consumer throughput — Read 100,000 messages and report the rate.
- Inspect a log segment — Print the messages in a log segment file on a broker's disk.
Related cheatsheets
- Ansible 2 cheatsheet — Run ad-hoc commands and playbooks, manage inventories, roles, collections and secrets with Ansible.
- Argo CD 3 cheatsheet — Install Argo CD, define Applications declaratively, and manage sync, diffs, history and rollbacks with the argocd CLI.
- AWS CLI 2 cheatsheet — Configure credentials and manage S3, EC2, Lambda, logs, containers and secrets with the AWS CLI v2.
- Azure CLI 2 cheatsheet — Sign in and manage resource groups, VMs, web apps, storage, Kubernetes, registries and secrets with the az command.
- Bash and Linux 5 cheatsheet — Everyday shell and Linux commands for files, searching text, permissions, processes and servers.
- Claude API cheatsheet — Call Claude from Python, TypeScript or curl: messages, streaming, thinking, tools, structured output, caching, batches and error handling.