DrDroid
Resource Cheatsheet

Kafka Topic

Quick reference guide and commands for Kafka Topic.

Download PDF

Connection

kafka-console-consumer.sh --bootstrap-server --topic
Connect as a consumer to a Kafka topic

kafka-console-producer.sh --broker-list --topic
Connect as a producer to a Kafka topic

Topic Management

kafka-topics.sh --bootstrap-server --list
List all available topics

kafka-topics.sh --bootstrap-server --create --topic --partitions --replication-factor
Create a new topic

kafka-topics.sh --bootstrap-server --delete --topic
Delete a topic

kafka-topics.sh --bootstrap-server --describe --topic
View details of a specific topic

Consumer Operations

kafka-console-consumer.sh --bootstrap-server --topic --from-beginning
Read all messages from the beginning of a topic

kafka-console-consumer.sh --bootstrap-server --topic --group
Consume messages as part of a consumer group

kafka-consumer-groups.sh --bootstrap-server --list
List all consumer groups

kafka-consumer-groups.sh --bootstrap-server --describe --group
Show consumer group details including lag

Producer Operations

kafka-console-producer.sh --broker-list --topic
Write messages to a topic

kafka-console-producer.sh --broker-list --topic --property parse.key=true --property key.separator=:
Produce messages with keys

Monitoring and Diagnostics

kafka-consumer-groups.sh --bootstrap-server --all-groups --describe
Check lag for all consumer groups

kafka-topics.sh --bootstrap-server --describe --under-replicated-partitions
List under-replicated partitions

kafka-configs.sh --bootstrap-server --entity-type topics --entity-name --describe
Show topic configuration

Configuration

kafka-configs.sh --bootstrap-server --entity-type topics --entity-name --alter --add-config =
Update topic configuration

kafka-configs.sh --bootstrap-server --entity-type topics --entity-name --alter --delete-config
Remove a topic configuration parameter