BeginnerOperations
How do you view Kafka consumer group lag?
Reference answer
Use the CLI: kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my-group. The output lists, per partition, CURRENT-OFFSET (the group's position), LOG-END-OFFSET (the partition's latest offset) and LAG, plus CONSUMER-ID, HOST and CLIENT-ID. Lag is LOG-END-OFFSET minus CURRENT-OFFSET, counted in records, not time. Programmatically, use the Admin client: listConsumerGroupOffsets for the group's committed offsets and listOffsets for the partitions' end offsets, then compare them. For monitoring, the consumer itself publishes JMX metrics in kafka.consumer:type=consumer-fetch-manager-metrics: records-lag per partition and records-lag-max (maximum lag in records for any partition). These are published by the consumer, not the broker, and are based on the current offset rather than the committed offset. Tools such as Prometheus exporters are separate from Apache Kafka.
Expected key concepts: kafka-consumer-groups.sh, bootstrap-server, describe, LAG, CURRENT-OFFSET, LOG-END-OFFSET, Admin, listConsumerGroupOffsets, JMX, records-lag
How did that feel?
Your own verdict, not the score. It shows up next to this question in the list, so you can come back to the shaky ones.