How-to · OpenTelemetry

How to Monitor Apache Kafka with OpenTelemetry

Monitoring Kafka with OpenTelemetry means collecting broker and consumer metrics through the OpenTelemetry Collector's Kafka receivers over OTLP, so streaming health, especially consumer lag, is fully visible..

Monitoring Kafka with OpenTelemetry means collecting broker and consumer metrics through the OpenTelemetry Collector's Kafka receivers over OTLP, so streaming health, especially consumer lag, is fully visible.

What to observe in Apache Kafka

The defining Kafka signal is consumer-group lag, how far each consumer group is behind the newest offset on each topic and partition, because lag that grows without bound means data is not being processed in time, and everything downstream goes stale. Around it you watch the broker fabric: under-replicated partitions, offline partitions, request latency, throughput, and broker disk usage.

Reading lag correctly means reading it per partition, not just as a group total: a single hot or stuck partition can hide inside a healthy-looking aggregate, and it is usually the partition, not the whole group, that is the incident.

How OpenTelemetry collects it

The OpenTelemetry Collector's kafkametrics receiver connects to the brokers and collects the fabric-level and consumer-level metrics, broker and partition counts, per-partition current and oldest offsets, in-sync replica counts, and consumer-group lag and offsets, without running an agent on the brokers. For broker JVM and internal metrics, the JMX receiver reads Kafka's MBeans over a JMX port.

Producers and consumers instrumented with OpenTelemetry add the other half: traces that follow a message from producer through the broker to the consumer, so you can see not just that lag exists but where in the pipeline a message stalls. The setup detail to get right is pointing kafkametrics at the bootstrap brokers with the correct protocol and credentials; consumer lag is derived from the difference between the partition's latest offset and the group's committed offset, so both must be readable.

Receiver metric names follow the kafkametrics receiver's conventions and can vary by Collector version; confirm against your build.

Key metrics to watch

The signals that explain most Kafka incidents:

SignalSourceWhat it tells you / watch for
kafka.consumer_group.lagkafkametrics receiverPer-group, per-partition lag. The single most important Kafka signal; watch the trend, not the instant value.
kafka.consumer_group.lag_sumkafkametrics receiverTotal lag per group; useful for a top-line view but hides hot partitions.
kafka.partition.replicas vs replicas_in_synckafkametrics receiverTheir difference is under-replicated partitions, the sign a broker is down or lagging.
kafka.partition.current_offset ratekafkametrics receiverProduce/consume throughput per partition; a sudden drop can mean a stalled producer or consumer.
consumer-group memberskafkametrics receiverMembers dropping to zero, or churning, indicates crashes or rebalance storms.
broker disk usagehost/JMXKafka retains data on disk; a full broker disk takes partitions offline.

What to put on a dashboard

A Kafka dashboard should surface lag and replication health first. Row one: consumer-group lag over time per group and topic (a rising line is the alarm), and the top partitions by lag to catch the hot-partition case. Row two: under-replicated partition count derived from replicas minus in-sync replicas, and offline partitions. Row three: throughput per topic and broker disk usage, so a stalled pipeline or a filling disk is visible early.

# consumer lag by group and topic (watch the slope, not the value)
kafka.consumer_group.lag by (group, topic)

# under-replicated partitions = replicas that are not in sync
kafka.partition.replicas - kafka.partition.replicas_in_sync

# throughput per partition (a drop can mean a stalled consumer)
rate(kafka.partition.current_offset[5m]) by (topic, partition)

Reading the signals: common failure modes

Growing consumer lag

Lag climbs steadily for a group while producers keep writing, so consumers are falling behind. Read it per partition: if one partition dominates, the consumer handling it is slow or stuck; if all rise together, the group is under-provisioned or repeatedly rebalancing. Scale consumers, fix the slow processing, or stop the rebalance loop.

Under-replicated partitions

The count of partitions whose replicas are not all in sync rises, meaning a broker is down or too slow to keep up, and durability is at risk. Identify the lagging broker from the fabric metrics; the cause is usually a broker under disk or network pressure, or a broker that has fallen out of the cluster.

Rebalance storms

Consumer-group membership churns and lag sawtooths as the group repeatedly rebalances, pausing consumption each time. The tell is members joining and leaving in the metrics. Causes include consumers exceeding the session timeout because processing is too slow, or unstable instances; tune timeouts and processing, or stabilise the consumers.

Example alert conditions

Starting thresholds to tune:

ConditionSignalMeaning
consumer_group.lag rising for 15mlagConsumers falling behind; data going stale.
replicas - replicas_in_sync > 0 for 5mreplicationUnder-replicated partitions; durability at risk.
offline partitions > 0availabilityData unavailable; a broker or disk has failed.
broker disk usage > 85%capacityApproaching the point where partitions go offline.

From monitoring to autonomous resolution

Ops Singularity's TelemetryOps ingests Kafka telemetry over OpenTelemetry, and its DataOps and Sentinel capabilities resolve streaming incidents, growing lag, a stalled consumer, an under-replicated partition, through governed Action Tickets. Explore TelemetryOps and DataOps.

Frequently asked questions

How do I monitor Kafka consumer lag with OpenTelemetry?

Use the OpenTelemetry Collector's kafkametrics receiver, which collects consumer-group lag per topic along with broker and topic metrics, exported over OTLP.

What are the key Kafka metrics to watch?

Consumer-group lag, under-replicated and offline partitions, request and produce latency, throughput, and broker disk usage.

See autonomous operations on your own stack.

Bring a real incident. We will show you Sentinel investigate, act and verify end to end, with every action reversible and audited.

Request a Demo → See TelemetryOps