Skip to main content
Backend & APIs

Apache Kafka CLI & Event Streaming

Enterprise

Topic administration, consumer groups, partition management, producer testing, offset resets, and cluster inspection.

Instant Copy & SearchProduction Flagged SyntaxCurrent Flag Reference

Apache Kafka CLI & Event Streaming Interactive Command Directory

Browse, search, and copy battle-tested commands & syntax recipes (16 Total Commands).

16+ Verified Recipes
Topic Creation--create, --partitions, --replication-factor
kafka-topics.sh --bootstrap-server localhost:9092 --create --topic orders --partitions 6 --replication-factor 3

Create a new distributed Kafka topic with partitions and replication factor.

List Topics--list
kafka-topics.sh --bootstrap-server localhost:9092 --list

List all active topics registered in the Kafka broker cluster.

Describe Topic--describe
kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic orders

Inspect partition leaders, replica brokers, and in-sync replica (ISR) lists.

Console Producer--property parse.key=true
kafka-console-producer.sh --bootstrap-server localhost:9092 --topic orders --property "parse.key=true" --property "key.separator=:",

Produce test events with explicit message keys and payload values from stdin.

Console Consumer--from-beginning, --property print.key=true
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic orders --from-beginning --property print.key=true

Stream and display all messages from the beginning of a topic with keys.

Consumer Groups--describe --group
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group order-processors

Monitor consumer group lag, current partition offsets, and active client IDs.

Offset Reset--reset-offsets --to-earliest
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group order-processors --topic orders --reset-offsets --to-earliest --execute

Rewind consumer group offsets to reprocess historic topic events.

Topic Configurationkafka-configs.sh, --alter
kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name orders --alter --add-config retention.ms=604800000,segment.bytes=1073741824

Dynamically adjust topic retention window to 7 days and segment roll size to 1GB without restarting cluster.

Offset TelemetryGetOffsetShell, --time -1
kafka-run-class.sh kafka.tools.GetOffsetShell --bootstrap-server localhost:9092 --topic orders --time -1

Query latest committed end-offset across all topic partitions to monitor ingestion throughput.

Consumer Group Health--state
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group order-processors --state

Inspect consumer group lifecycle state (Stable, Rebalancing, Dead, or Empty) to identify partition rebalance storms.

Log Directorieskafka-log-dirs.sh, --describe
kafka-log-dirs.sh --bootstrap-server localhost:9092 --describe --topic-list orders

Inspect physical disk partition allocation and log segment byte footprint across broker mount points.

Broker Compatibilitykafka-broker-api-versions.sh
kafka-broker-api-versions.sh --bootstrap-server localhost:9092

Verify broker API version support matrix and protocol negotiation limits across nodes.

Partition Rebalancingkafka-reassign-partitions.sh
kafka-reassign-partitions.sh --bootstrap-server localhost:9092 --reassignment-json-file reassign.json --execute

Execute cluster-wide partition reallocation across brokers to alleviate disk hot-spots.

Security & ACLskafka-acls.sh, --add
kafka-acls.sh --bootstrap-server localhost:9092 --add --allow-principal User:alice --operation Read --operation Write --topic orders

Grant fine-grained read and write permissions to authenticated SASL/SCRAM service principals.

Log Segment Inspectionkafka-dump-log.sh
kafka-dump-log.sh --files /var/lib/kafka/data/orders-0/00000000000000000000.log --print-data-log

Inspect and deserialize low-level binary record batches and headers directly from on-disk segment files.

Offset Replay--reset-offsets, --shift-by
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group order-processors --topic orders --reset-offsets --shift-by -100 --execute

Rewind consumer group read offset by 100 messages for reprocessing and debugging production errors.

Zero Setup100% In-Browser Execution

Companion Developer Tools & Playgrounds

Accelerate command execution and syntax debugging with HelloAIHub suite of interactive tools.

Explore all developer tools

Apache Kafka CLI & Event Streaming: Command Groups & Quick Index

16 indexed entries across 16 sections
Topic Creation1 items
List Topics1 items
Describe Topic1 items
Console Producer1 items
Console Consumer1 items
Consumer Groups1 items
Offset Reset1 items
Topic Configuration1 items
Offset Telemetry1 items
Consumer Group Health1 items
Log Directories1 items
Broker Compatibility1 items
Partition Rebalancing1 items
Security & ACLs1 items
Log Segment Inspection1 items
Offset Replay1 items

Highlighted Flags & Syntax Examples in Apache Kafka CLI & Event Streaming

kafka-topics.sh --bootstrap-server localhost:9092 --create --topic orders --partitions 6 --replication-factor 3

Create a new distributed Kafka topic with partitions and replication factor.

Flags: --create, --partitions, --replication-factor
kafka-topics.sh --bootstrap-server localhost:9092 --list

List all active topics registered in the Kafka broker cluster.

Flags: --list
kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic orders

Inspect partition leaders, replica brokers, and in-sync replica (ISR) lists.

Flags: --describe
kafka-console-producer.sh --bootstrap-server localhost:9092 --topic orders --property "parse.key=true" --property "key.separator=:",

Produce test events with explicit message keys and payload values from stdin.

Flags: --property parse.key=true

Frequently Asked Questions

Expert recommendations, common traps, and production best practices for Apache Kafka CLI & Event Streaming.

How does Kafka guarantee message ordering?

Kafka guarantees strict total message ordering only within a single partition. Messages published with the same message key hash to the same partition and are consumed in the exact order written.

What is Consumer Lag and why is it a critical metric?

Consumer Lag measures the delta between the latest log end offset in a partition and the current offset processed by the consumer group. High or growing lag indicates that consumers are falling behind ingestion rate.

What is consumer lag in Kafka and how do you monitor and alert on it?

Consumer lag is the delta between the latest offset written to a partition (Log End Offset) and the offset committed by the consumer group. High or growing lag indicates that consumers are processing messages slower than producers are publishing, signaling the need for partition scale-out or consumer optimization.

What is the difference between log compaction and log deletion in Kafka topic retention?

Log deletion discards log segments older than retention.ms or larger than retention.bytes. Log compaction retains the most recent message value for every unique record key indefinitely, garbage-collecting older versions with identical keys. Compaction is ideal for state stores and changelogs.

How does Kafka KRaft mode eliminate ZooKeeper dependencies?

Kafka Raft (KRaft) metadata mode runs an internal Raft consensus quorum directly inside Kafka brokers. This eliminates external ZooKeeper clusters, accelerates metadata propagation, reduces partition recovery times, and allows clusters to scale to millions of partitions.

What is the idempotence producer setting (enable.idempotence=true) and how does it prevent duplicates?

When enable.idempotence is enabled, each producer is assigned a unique Producer ID (PID), and each batch is stamped with a monotonic Sequence Number. If network retries resend a batch already committed by the broker, the broker deduplicates the message based on the sequence number without data loss.

Cross-Hub Skill Acceleration

Combine command lookups with active coding interviews and complete career paths.

Need More Cheat Sheets?

Explore developer cheat sheets and syntax guides on HelloAIHub.

Browse All Cheat Sheets