Hackaholic
Hackaholic

Reputation: 19733

Kafka List all partition with no leader

In my kafka Cluster there are more than 2k topics and each topic has 5 partitions. I want list only that partitions which has no leader.

I can go can check for each topic using the below syntax:

kafka-topics.sh --describe --topic <topic_name> --zookeeper <zookeeper_ip>:port

But the problem is there are 2k+ topics, can't be done manually. I can also write a script to loop over each topic and get the partition with no leader. But i am interested in some efficient way to get the information.

Upvotes: 4

Views: 3528

Answers (1)

Mickael Maison
Mickael Maison

Reputation: 26875

Using kafka-topics.sh you can specify the --unavailable-partitions flag to only list partitions that currently don't have a leader and hence cannot be used by Consumers or Producers.

For example:

kafka-topics.sh --describe --unavailable-partitions --zookeeper <zookeeper_ip>:port

Upvotes: 5

Related Questions