Search code examples
pythonapache-kafkakafka-consumer-apiconfluent-kafka-python

Confluent-Kafka-Python: Get lag per topic partition


With confluent-kafka-python was wondering if via the Admin API or any of the other api's, I can fetch lag per topic partition? Found this link to be helpful but wanted to check if there is a direct api available instead?


Solution

  • You don't need the AdminClient.

    You can get the high watermark of a topic's partitions and you can get the consumer's current/committed positions directly from the Consumer instance, as the linked example shows... Subtract these, and you have the lag.

    Alternatively, you can install tool like Burrow and use its REST API from Python