In my app I will perform some kind of health check of my Kafka cluster.
Currently I make a TopicMetadataRequest
to detect dead brokers:
Future {
// this will fail if Kafka is unavailable
consumer.send(new TopicMetadataRequest(Seq("health-check-topic"), 1))
}
Unfortunately this call produces a huge network traffic, because of Cluster topology/settings.
Is there a better way to check kafka brokers? What I need is something simple like true/false
indicator.
The kafka-check command performs multiple checks on the health of the cluster. Each subcommand will run a different check. The tool can run on the broker itself or on any other machine, and it will check the health of the entire cluster.
Increasing the number of partitions and the number of brokers in a cluster will lead to increased parallelism of message consumption, which in turn improves the throughput of a Kafka cluster; however, the time required to replicate data across replica sets will also increase.
Answer : To find the Kafka port number - locate the Kafka server. properties file. Typically the server. properties file will have the information required.
Kafka Brokers Connecting to one broker bootstraps a client to the entire Kafka cluster. For failover, you want to start with at least three to five brokers. A Kafka cluster can have, 10, 100, or 1,000 brokers in a cluster if needed.
You can also use Zookeeper API to get the broker list as follows:
ZooKeeper zk = new ZooKeeper(KafkaContextLookupUtil.getZookeeperConnect().getZkConnect(), 10000, null);
List<String> ids = zk.getChildren("/brokers/ids", false);
List<Map> brokerList = new ArrayList<>();
ObjectMapper objectMapper = new ObjectMapper();
for (String id : ids) {
Map map = objectMapper.readValue(zk.getData("/brokers/ids/" + id, false, null), Map.class);
brokerList.add(map);
}
return brokerList;
If you want to build your own health check, this is a current (January 2020) list of KIPs covering health checks:
Regarding Harvinder Singh's currently accepted answer:
Kafka Manager is great but it's evolving slowly. There's of course Confluent Control Center - a part of Confluent Platform, but you'll need a license for it. Confluent is a company founded by the team that built Apache Kafka. I've heard about akHQ (ex KafkaHQ) (HackerNews story). Here's a list of management consoles maintained on Apache Kafka Confluence page (check URLs there):
If you don't need GUI, there are also:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With