Skip to the content.

Consumer lag monitoring refers to tracking the delay (lag) between the messages produced to a system (like Kafka) and the messages consumed/processed by consumers.

Let’s break it down:


🔹 What is Consumer Lag?

👉 Example:

This means the consumer is 50 messages behind.


🔹 Why is Consumer Lag Important?


🔹 How to Monitor Consumer Lag?

  1. Kafka tools

    • kafka-consumer-groups.sh --describe shows lag per consumer group.
    • Metrics exposed via JMX (Java Management Extensions).
  2. Monitoring systems

    • Prometheus + Grafana (via Kafka Exporter or Burrow).
    • Confluent Control Center.
    • LinkedIn’s Burrow (specialized lag monitoring).
  3. Custom monitoring

    • Fetch partition end offsets.
    • Compare with committed offsets of consumer groups.
    • Log / alert if lag crosses threshold.

🔹 What Consumer Lag Monitoring Involves


✅ In short: Consumer lag monitoring is the practice of tracking how far behind consumers are from the latest produced data, to ensure real-time or near real-time processing and detect system bottlenecks.


“Replay from Offset”?

👉 Replay from offset means: You can reset the consumer’s offset to an earlier point in the log and reprocess old messages.


🔹 Why Replay from Offset?


🔹 How to Replay from Offset in Kafka

There are a few ways:

1. Change Offset with CLI

Use Kafka’s kafka-consumer-groups.sh:

# Reset offsets for a consumer group to a specific offset
kafka-consumer-groups.sh \
  --bootstrap-server <BROKER> \
  --group <CONSUMER_GROUP> \
  --topic <TOPIC> \
  --reset-offsets --to-offset <OFFSET_NUMBER> \
  --execute

Other options:


2. Consumer API (Java / Spring Kafka, etc.)

Manually seek to an offset:

consumer.seek(new TopicPartition("my-topic", 0), 100);

This makes the consumer start reading from offset 100.


3. Delete the Consumer Group Offsets

If you delete a consumer group, when it reconnects, Kafka treats it as new and starts at earliest or latest, depending on the auto.offset.reset policy.


🔹 Key Points


✅ In short: Replay from offset = resetting the consumer position to an earlier offset so you can re-read and reprocess historical messages.