The purpose of Describe Kafka Topic is to know the leader for the topic, the broker instances acting as replicas for the topic, and the number of partitions of a Kafka Topic that has been created with.

For creating a Kafka Topic, refer Create a Topic in Kafka Cluster.

Describe Topic

Consider there are three broker instances running on a local machine and to know which kafka broker is doing what with a kafka topic(say my-topic), run the following command

$ bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-topic

Replacemy-topic  with your topic name. And also, it is assumed that you are running kafka with default configuration (zookeeper running at 2181).

$ bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-topic
Topic:my-topic    PartitionCount:1 ReplicationFactor:3 Configs:
    Topic: my-topic    Partition: 0 Leader: 1 Replicas: 1,2,0 Isr: 1,2,0

The result explains that

Leader: 1 meaning broker instance 1 is responsible for all reads and writes for the given partition. Reads and Writes are done by Kafka Consumers and Kafka Producers respectively.

Replicas: 1,2,0 meaning broker instances 0, 1 and 2 are acting as nodes that replicate the log irrespective of one being a leader.

Isr: 1,2,0 meaning broker instances 1, 2 and 0 are in-sync replicas.

PartitionCount:1 and ReplicationFactor:3 are the details used while creating the topic.

Now Kafka Producers may send messages to the Kafka topic, my-topic and Kafka Consumers may subscribe to the Kafka Topic.

ADVERTISEMENT

Conclusion

In this Apache Kafka Tutorial – Describe Kafka Topic, we have learnt to check Kafka Broker Instance that is acting as leader for a Kafka Topic, and the Broker Instances acting as replicas and in-sync replicas for the Kafka Topic.