Is there a way to find whole kafka lag for all consumers assigned to same consumer group?
I could only get the lag for the assigned partition. For e.g. Assume only one partition is assigned to a consumer, below code only brings lag for that partition. Not for other partition.
Set<TopicPartition> partitionSet = consumer.assignment();
Map<TopicPartition, Long> endOffsets = consumer.endOffsets(partitionSet);
for(TopicPartition tp : partitionSet) {
LOG.info("Topic:{}, EndOffset:{}, currentOffset:{}, LAG:{}",
tp.topic(), endOffsets.get(tp), consumer.position(tp), endOffsets.get(tp)-consumer.position(tp));
}
Basically, would like to find the sum of lags from all partitions to understand how much all consumers(same group) of a topic is lagging behind.
Also, is there any api available similar to kafka-consumer-groups, and pass bootstrap-server and group as arguments to find the lag?
./kafka-consumer-groups.sh --bootstrap-server --group --describe