49 min read

Kafka Consumer Lag: A Practical Guide to Key Metrics

Interpret Kafka consumer lag using client metrics, committed offsets and time-based checks. Follow read-only commands to investigate processing delays.

Kafka Consumer Lag: A Practical Guide to Key Metrics

Kafka consumer lag is not one number. It is at least four: records-lag and records-lag-max from the Java client, committed-offset lag from the group coordinator, and derived time lag. This guide separates them, shows why the CLI and the client disagree, and gives a read-only investigation procedure that derives thresholds from your own freshness SLO instead of borrowed constants.

What Kafka Consumer Lag Actually Measures

The metric most teams mean when they say "lag" is committed-offset lag: for each partition, the broker's log end offset minus the group's last committed offset. The Apache Kafka 4.1 monitoring documentation publishes log end offset as kafka.log:type=Log,name=LogEndOffset,topic=([-.\w]+),partition=([0-9]+) and log start offset alongside it, which is why the CLI can compute lag without contacting your consumer processes at all. The kafka-consumer-groups tool reads committed offsets from the group coordinator and subtracts them from the log end offset it queries from the partition leader.

That definition hides two moving parts. First, the log end offset is broker-side and keeps advancing as producers write, whether or not anyone consumes. Second, the committed offset is whatever the consumer last chose to commit, which may trail its actual fetch position by one or many poll cycles depending on enable.auto.commit and your commit interval. A consumer can therefore be reading at full speed while committed-offset lag grows, and it can be idle while committed-offset lag stays flat.

The rest of this guide treats each lag figure as a separate signal with its own offset basis, aggregation window and partition scope. None of them is a substitute for the others, and none of them alone tells you whether records are arriving in your lakehouse on time. If your pipeline is fed by database changes rather than application producers, the lag numbers above are only half the story — see how CDC replay and ingestion patterns behave when a connector restarts and re-delivers events.

The Four Lag Numbers Engineers Conflate

The table below is the reference artifact for the rest of the article. Read the "computed from" column first: the disagreements that look like bugs almost always trace back to a different offset basis or a different sampling window.

Metric

Published where

Computed from

What it tells you

What it does not tell you

records-lag

Java client JMX, per partition: kafka.consumer:type=consumer-fetch-manager-metrics,partition="{partition}",topic="{topic}",client-id="{client-id}"

The latest lag of the partition, based on the consumer's current position, not its committed offset

How far this consumer instance's fetch position sits behind the end of the partition right now

What has been durably committed; anything about partitions this instance does not own

records-lag-max

Java client JMX, client level: kafka.consumer:type=consumer-fetch-manager-metrics,client-id="{client-id}"

The maximum lag in records for any partition in the sampling window; the Kafka docs state it is based on current offset and not committed offset

Worst-case per-partition backlog as seen by one client, useful for spotting a single hot partition

A sum across partitions; a group-wide figure; a committed-offset backlog

Committed-offset lag

kafka-consumer-groups --describe, LAG column

Log end offset minus the group's committed offset, per partition, at the moment the command runs

The durable backlog: records written but not yet committed as processed

Whether the consumer is currently fetching, healthy, or even running

Time lag

Derived by you; not a native Kafka metric

Current wall-clock time minus the timestamp of the newest uncommitted record, or an estimate from backlog divided by consume rate

How stale the oldest unprocessed record is, which maps directly to a freshness objective

Anything precise during bursts, rebalances or partition skew, where the rate assumption breaks

End-to-end processing delay

Your application, sink or query layer

Observation time minus record event time, measured after the sink has made the record queryable

Whether the record is actually usable downstream, including sink and compaction latency

Kafka-internal causes; it is not a Kafka metric and cannot be read from JMX

Two consequences follow. Java client metrics are not identical to kafka-consumer-groups CLI values, because the client reports its own fetch position over a sampling window while the CLI reports committed offsets at a point in time. And time lag and processing delay are not Kafka metrics at all: they are quantities you construct, so their accuracy depends entirely on how you compute them.

Why the Java Client and the CLI Disagree

A consumer's position and its committed offset are deliberately separate concepts. The KafkaConsumer Javadoc describes the position as the offset of the next record to be fetched, advancing automatically as records are returned, while the committed offset moves only when the consumer commits. A consumer that polls a large batch and processes it for thirty seconds has already advanced its position past those records; its records-lag reflects the advanced position, while the CLI still sees the last commit.

Three mechanical differences explain most discrepancies:

  • Offset basis. records-lag and records-lag-max are computed from the current position. The CLI's LAG column is computed from the committed offset. A consumer that fetches ahead of its commits will always show lower client lag than CLI lag.

  • Aggregation window. Client metrics are sampled over the metrics window configured by metrics.num.samples and metrics.sample.window.ms, so records-lag-max is a maximum observed within that window. The CLI is a single snapshot taken when you run it.

  • Partition scope. records-lag-max is a client-level maximum across the partitions that instance owns, not a sum and not a per-partition value. The CLI table lists every partition in the group, including partitions owned by other members.

Treat a gap between the two as information rather than an error. A large gap usually means commits are infrequent relative to fetch volume, which is a durability and duplicate-processing question, not a throughput question.

Reading Lag from the Command Line Without Changing Anything

Every command in this section is read-only. Replace BOOTSTRAP with your broker list, for example broker1.example.com:9092,broker2.example.com:9092, and GROUP with the consumer group ID. The option semantics below follow the basic Kafka operations documentation and the Confluent kafka-consumer-groups tool reference.

Enumerate groups, then filter by state to find groups that are not consuming:

kafka-consumer-groups.sh --bootstrap-server BOOTSTRAP --list
  kafka-consumer-groups.sh --bootstrap-server BOOTSTRAP --list --state stable,empty
  

The per-partition offset table is the core diagnostic. --describe defaults to the offsets sub-action:

kafka-consumer-groups.sh --bootstrap-server BOOTSTRAP --describe --group GROUP
  

Hypothetical output, not measured — the numbers below are illustrative only:

GROUP           TOPIC      PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG   CONSUMER-ID     HOST          CLIENT-ID
  orders-ingest   orders     0          1042188         1042188         0     consumer-1-abc  /10.0.1.12    consumer-1
  orders-ingest   orders     1          992041          1104773         112732 consumer-2-def  /10.0.1.13    consumer-2
  orders-ingest   orders     2          1003117         1003117         0     consumer-1-abc  /10.0.1.12    consumer-1
  

Group state and member assignment answer whether the group is healthy before you interpret any lag number:

kafka-consumer-groups.sh --bootstrap-server BOOTSTRAP --describe --group GROUP --state
  kafka-consumer-groups.sh --bootstrap-server BOOTSTRAP --describe --group GROUP --members --verbose
  

Hypothetical output, not measured:

COORDINATOR (ID)      ASSIGNMENT-STRATEGY  STATE   #MEMBERS
  broker1.example.com:9092 (1)  range         Stable  2
  

One caveat belongs here rather than in a footnote. Offset resets rewrite the group's committed offsets, which means they change the very baseline every lag reading is built on. Because this guide is scoped to read-only monitoring, it stops at reading state and does not include reset commands. When a reset does happen outside this scope, treat the resulting lag change as a baseline shift, not as evidence that consumption caught up.

Investigating a Lag Alert: A Numbered Procedure

Work these steps in order. Each one is cheaper and safer than the next, and each rules out a class of cause before you touch anything that writes state.

  1. Confirm group state and member count. Run --describe --group GROUP --state. A Stable group with the expected member count rules out a dead consumer; Empty or PreparingRebalance changes the entire interpretation, so resolve it before reading lag.

  2. Capture the per-partition table. Run --describe --group GROUP and compare LAG across partitions. Lag concentrated on one or two partitions points to a hot key or a single slow member; uniform lag across all partitions points to a group-wide throughput or downstream bottleneck.

  3. Compare with the client's records-lag-max. If client lag is far below CLI lag, the consumer is fetching ahead of its commits. That rules out a stalled fetch loop and raises a commit-interval or processing-time question.

  4. Check records-consumed-rate against the produce rate. The client metric is the average records consumed per second; compare it with the topic's incoming rate from broker metrics such as MessagesInPerSec. A consume rate persistently below the produce rate means the consumer cannot keep up; a consume rate at or above it with rising lag means the backlog predates the current window.

  5. Inspect rebalance counters. rebalance-rate-per-hour, last-rebalance-seconds-ago and failed-rebalance-total distinguish a steady-state throughput problem from churn. Frequent rebalances rule out a simple capacity fix and point at session timeouts or long poll processing.

  6. Check poll behaviour. time-between-poll-max and poll-idle-ratio-avg show whether the consumer is processing-bound. A high idle ratio means poll() is waiting on your code, not on the broker, which rules out network or fetch-size tuning as the fix.

  7. Decide whether the backlog is recoverable before anyone changes offsets. If the consume rate shows the group can drain the backlog inside the SLO, scale or fix the bottleneck and leave offsets alone. If it cannot, and the business accepts skipping records, hand the decision to whoever owns the offsets — a reset is a deliberate governance action, not a triage step, and this read-only procedure ends with the evidence in hand rather than a command to run.

Rebalances, Inactive Groups and Offset Resets

Three situations make lag numbers misleading, and each has a different remedy.

Rebalances. What a rebalance does to your lag numbers depends on the assignment protocol. With the eager protocol, every member revokes all its partitions and rejoins, so the whole assignment is released and rebuilt; with the cooperative protocol, members keep their partitions and only the ones that must move are revoked and reassigned incrementally. Client-side lag metrics can therefore freeze, gap, or reset for the partitions in motion while committed offsets stay at their last committed values. Which partitions that touches, and for how long, depends on the protocol, the assignor and how much the assignment actually changed — a stable assignment that only adds a member may leave most consumers undisturbed. The gap is bounded by how long the rebalance takes: rebalance-latency-max measures the maximum time taken for a group rebalance, and partitions-revoked-latency-max bounds the time spent in your onPartitionsRevoked callback. A long revoke callback delays the whole group, so slow cleanup work in that listener shows up as lag for every member.

Inactive or empty groups. The CLI reports committed offsets even when no member is connected. Lag then reflects the last commit rather than current consumption, and it grows as producers write. An Empty group with rising lag means consumption has stopped entirely — a crashed deployment, a paused connector, a group ID typo — not that a consumer is slow. Check --state before you scale anything.

Offset resets and retention. The auto.offset.reset consumer setting defaults to latest and governs behaviour when there is no initial offset or the current offset no longer exists on the server, for example because the data was deleted; valid values include latest, earliest, none and by_duration. With none, the consumer throws OffsetOutOfRangeException instead of silently repositioning.

Retention is a different mechanism, and it does not do what many runbooks claim. Lag computed as log end offset minus committed offset is pure arithmetic: if retention deletes records below the committed offset, both end and committed offsets are unchanged, so the subtraction is unchanged too. Retention only makes lag misleading when it overtakes the committed offset — the group's position now points below the log start offset, so the consumer is out of range and must reposition using auto.offset.reset, or throws if that is set to none. At that moment the committed offset is adjusted to the log start offset and the lag baseline changes. A lag drop, then, usually points at a reset or an offset adjustment rather than at retention deleting unread records in place.

Transactions, read_committed and the Last Stable Offset

For transactional topics, log end offset minus committed offset overstates the backlog a consumer can actually process. Per the consumer configuration reference, messages are always returned in offset order, so in read_committed mode poll() returns only messages up to the last stable offset (LSO), which is one less than the offset of the first open transaction. Records appearing after messages belonging to ongoing transactions are withheld until those transactions complete, and read_committed consumers cannot read up to the high watermark while transactions are in flight.

The practical consequence: the consumer's effective end offset is the LSO, not the log end offset. The KafkaConsumer Javadoc confirms that with isolation.level=read_committed, endOffsets() returns the Last Stable Offset. A lag figure computed against the log end offset therefore includes records the consumer is not yet permitted to read, and it will look large even when the consumer is perfectly healthy.

Measure transactional topics against the LSO, and watch for long-running open transactions: a single transaction left open by a stuck producer holds the LSO in place and pins apparent lag for every read_committed consumer on that partition. If lag is flat and large on a transactional topic, look for the open transaction before you look at consumer capacity.

Deriving Thresholds from Your Own SLO

There is no universal lag threshold, and any article or vendor that supplies one is guessing about your traffic. Derive the number instead. The method below is a reasoning procedure, not a measured benchmark.

  1. State a freshness objective in time. For example: records must be queryable within 60 seconds of production. That is an SLO you can defend to the business. If you'd rather anchor that objective in something measurable end to end, the data freshness SLA approach shows how to make freshness verifiable instead of asserted.

  2. Measure the topic's sustained produce rate in records per second over a representative window, using broker metrics such as MessagesInPerSec.

  3. Convert the objective into a record backlog. At a sustained rate of 2,000 records per second, a 60-second objective corresponds to roughly 120,000 records of backlog. That number is your committed-offset lag alert threshold for that topic at that rate.

  4. Use the SLO directly for time lag. If you can compute time lag honestly, the threshold is the objective itself, with no conversion.

  5. Adjust records-lag-max for skew and window. Because it is a per-partition maximum over a sampling window, its threshold must reflect your worst partition and the window length, not the group total.

A threshold derived at peak rate will be too loose off-peak and too tight during a burst, because the same record backlog represents very different delays at different rates. Pair the static threshold with a rate-of-change alert — lag growing faster than the consume rate can absorb — so a burst is caught before the absolute number crosses.

Where Lag Monitoring Fits in a Data Platform

Kafka lag is a leading indicator, not the final answer. It tells you whether records have been committed as consumed; it does not tell you whether they are queryable in the lakehouse or warehouse downstream. A consumer can be fully caught up while the sink is behind on compaction, merge or refresh, and a lag-only alert will miss that case entirely. Pair every lag alert with a downstream freshness check, so ingestion freshness and query freshness are observed together rather than inferred from each other. On the Singdata AI Lakehouse, both can be monitored from the same platform, and Lakehouse Studio provides the pipeline scheduling and operations view where those signals sit next to each other.

Frequently Asked Questions

Why do records-lag and the CLI's LAG column disagree for the same consumer group?

Three differences explain it, all covered in the comparison table above. The offset basis differs: records-lag uses the consumer's current fetch position, which advances ahead of the last commit, while the CLI's LAG column uses the committed offset. The aggregation differs: client metrics are sampled over a metrics window, while the CLI is a point-in-time snapshot. The partition scope differs: records-lag-max is a client-level maximum across the partitions that instance owns, not a group-wide sum. A consumer that fetches ahead of its commits will always show lower client lag than CLI lag.

Which signal should drive an alert for a freshness SLO: records-lag, records-lag-max, committed-offset lag or time lag?

Use committed-offset lag or time lag. Both are grounded in what has actually been committed, so they measure durable backlog rather than in-flight fetch state. records-lag and records-lag-max are diagnostic signals for consumer health: they tell you whether a specific instance is fetching and how skewed its partitions are, but they move with the fetch position and can look healthy while commits fall behind. Alert on the SLO signal; use the client metrics to explain it once it fires.

What does lag mean for an inactive or empty consumer group?

The CLI still reports committed offsets for a group with no active members, so LAG reflects the last commit and grows as producers write. An Empty group with rising lag means consumption has stopped, not that the consumer is slow — confirm the state with --describe --group <GROUP_ID> --state.

How does a rebalance change the lag numbers I am looking at?

It depends on the assignment protocol and what changed. Under the eager protocol, all members revoke every partition and rejoin, so the entire assignment is released and rebuilt. Under the cooperative protocol, members keep their partitions and only the ones that must move are revoked and reassigned, so the disturbance is narrower. In both cases client-side lag metrics can freeze or gap for the partitions in motion while committed offsets stay at their last committed values. rebalance-latency-max and partitions-revoked-latency-max bound how long that disruption lasts; consumption then resumes from the committed offset.

Does retention deletion shrink log-end-minus-committed lag?

Not by itself. If retention deletes records below the committed offset, both the log end offset and the committed offset are unchanged, so their difference is unchanged too — the arithmetic simply doesn't move. Retention becomes a real problem when it overtakes the group's position: the committed offset then falls below the log start offset, the consumer is out of range, and the group repositions via auto.offset.reset (or throws OffsetOutOfRangeException when it is set to none). The baseline changes at that point. A pure offset reset also rewrites the committed offset and shifts the baseline with no consumption involved, so a sudden drop in LAG is evidence of a reset or repositioning first, not proof the consumer caught up.

Primary Sources and Refresh Notes

The definitions, metric names and command options in this guide come from the Apache Kafka 4.1 documentation and the KafkaConsumer API reference, accessed 2026-11-30. This article was last updated on the same date.

Metric names, default values and CLI flags change between Kafka releases. Re-check each one against the release you actually run before encoding it in an alert rule or a runbook.

Related Articles