# How to check lags for each partition of topics that a consumer group has subscribed to?

**URL:** <https://forum.confluent.io/t/how-to-check-lags-for-each-partition-of-topics-that-a-consumer-group-has-subscribed-to/1025>\
**Category:** Clients\
**Created:** [24 February 2021 23:35 UTC](https://forum.confluent.io/t/how-to-check-lags-for-each-partition-of-topics-that-a-consumer-group-has-subscribed-to/1025 "2021-02-24T23:35:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaobol](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@shaobol](https://forum.confluent.io/u/shaobol)\
**Post date:** [24 February 2021 23:35 UTC](https://forum.confluent.io/t/how-to-check-lags-for-each-partition-of-topics-that-a-consumer-group-has-subscribed-to/1025/1 "2021-02-24T23:35:54Z")

</div>

Hi Robin, thanks for your blogs and they are really helpful. Actually I have a question on how to check lags for each partition of topics that a consumer group has subscribed. Basically I’m running a Kafka cluster on AWS MSK, and on my Kafka client machine I was able to check the lags by using the Kafka cli:  
kafka-consumer-groups --describe --group --bootstrap-server

I’d love to programmatically implement this functionality. Do you have any suggestions on how to achieve that using Golang, or is there any REST API I can call? Thanks and looking forward to your reply!

---

<div class="post-metadata">

**Author:** ![jeqo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/jeqo/32/185_2.png) [@jeqo](https://forum.confluent.io/u/jeqo)\
**Post date:** [26 February 2021 10:42 UTC](https://forum.confluent.io/t/how-to-check-lags-for-each-partition-of-topics-that-a-consumer-group-has-subscribed-to/1025/2 "2021-02-26T10:42:43Z")

</div>

Hi @shaobol!  
I don’t have experience with golang clients, but Admin APIs can be used to collect this information: AdminClient has 2 operations that help to calculate consumer group lag:

- [listConsumerGroupOffsets](http://kafka.apache.org/26/javadoc/org/apache/kafka/clients/admin/Admin.html#listConsumerGroupOffsets-java.lang.String-)
- [listOffsets](http://kafka.apache.org/26/javadoc/org/apache/kafka/clients/admin/Admin.html#listOffsets-java.util.Map-)  
Check if your golang client supports these.

Comparing offsets _stored in Kafka `_consumer-offsets` topic_ with the latest offset from a Topic Partition, consumer lag can be calculated.

Here is an example in Java: [kafka-connect-restart-by-lag/App.java at 16d2a7c271f297a3c492f478d6c589479f68ffd5 · jeqo/kafka-connect-restart-by-lag · GitHub](https://github.com/jeqo/kafka-connect-restart-by-lag/blob/16d2a7c271f297a3c492f478d6c589479f68ffd5/src/main/java/com/github/jeqo/kafka/App.java#L53-L70)

There are some tooling to monitor lags that you might find helpful:

- [GitHub - seglo/kafka-lag-exporter: Monitor Kafka Consumer Group Latency with Kafka Lag Exporter](https://github.com/lightbend/kafka-lag-exporter)
- [GitHub - linkedin/Burrow: Kafka Consumer Lag Checking](https://github.com/linkedin/Burrow)

HTH,  
Jorge.
