A simple, opinionated ruby script for checking the health of a kafka cluster
- The script reads kafka's
server.properties
file to determine the zookeeper hosts kafka is using - The script connects to zookeeper and reads the info of all the brokers in the cluster from
/brokers/ids
- The script then uses
kafka-topics.sh
to get a list of topics - It uses
--describe
on each topic to get the details of each topic - It prints out the list of brokers and their details, such as ID, IP address, hostname
- It prints out a list of topics, and for each topic it lists out the replication factor and partition count
- Set the script to be executable
chmod +x kafka_status.rb
-
Place the script somewhere like
/usr/local/bin/kafka_status
-
Run the script, e.g.
bburton@lookout-kafka-bburton-2:~$ /usr/local/bin/kafka_status
Kafka Cluster Status: bburton
The members of this cluster are:
Broker: lookout-kafka-bburton-1
Broker ID: 169869504
Broker IP: 10.1.1.11
Broker: lookout-kafka-bburton-2
Broker ID: 169869810
Broker IP: 10.1.1.12
Broker: lookout-kafka-bburton-0
Broker ID: 169869792
Broker IP: 10.1.1.10
This cluster has the following topics:
Topic: bburton.test3
Replication Factor: 3
Partition Count: 8
Topic: bburton.test2
Replication Factor: 1
Partition Count: 1
Topic: bburton.test1
Replication Factor: 1
Partition Count: 1