Skip to content

Klag: Kafka Consumer Lag Exporter

Know when your consumers fall behind, before it becomes a problem.

Consumer lag is the gap between Kafka’s log-end offset and a consumer group’s committed offset. It is a proxy for work the group has not acknowledged, not proof of completed business processing. Left unmonitored, growing lag means stale downstream data and silent failures when consumer groups die. Monitoring lag and group health is an essential operational practice for production Kafka; Klag is one way to ship those signals to your observability stack.

Lag velocity

Know if lag is growing or shrinking, and catch problems before they escalate.

Time-based lag

See lag in seconds/minutes, with time-to-close estimates, instead of raw message counts.

Hot partition detection

Find partitions with uneven load causing bottlenecks, via statistical outliers.

Group state tracking

Alert on preparing_rebalance, completing_rebalance, dead, or empty states.

Data loss prevention

Alert before lag exceeds retention and messages are lost forever.

Request batching

Safely monitor large clusters without overwhelming brokers.

Terminal window
docker run -e KAFKA_BOOTSTRAP_SERVERS=broker.example.com:9092 \
-e METRICS_REPORTER=prometheus \
-p 8888:8888 \
themoah/klag:latest

Replace broker.example.com:9092 with a broker address that resolves and is reachable from inside the Klag container. Use Docker network or service DNS for Kafka in another container. On Docker Desktop, host.docker.internal:9092 reaches Kafka on the host; on Linux Docker, add --add-host=host.docker.internal:host-gateway (or use the host gateway IP directly).

Metrics land at http://localhost:8888/metrics. See the Quick Start for native image, Helm, and Docker env-file options.

Klag exposes an opt-in, read-only MCP endpoint so SRE and dev agents can query lag, find lagging groups, and run composite diagnose checks, served from an in-memory snapshot, never touching your brokers.


Inspired by kafka-lag-exporter (archived 2024). Read the introductory blog post.