Operating large-scale Apache Kafka clusters in production requires vigilant telemetry. A cluster can appear healthy on basic CPU and memory dashboards while silently dropping consumer groups, falling hours behind SLA processing targets, or risking data loss due to degraded replication quorums.
This guide details the Four Golden Metric Signals of Apache Kafka production monitoring, their underlying JMX MBean paths, and Prometheus alert thresholds.
1. The Four Golden Signals of Kafka Telemetry
2. Metric 1: UnderReplicatedPartitions & OfflinePartitions (P0 Alarm)
When a broker dies, experiences network partitioning, or suffers disk I/O stall, follower replicas fall behind and are expelled from the In-Sync Replicas (ISR) list.
Key JMX Metrics & Thresholds:
| Metric Name | JMX MBean Path | Critical Threshold | Meaning & Action |
|---|---|---|---|
UnderReplicatedPartitions | kafka.server:type=ReplicaManager,name=UnderReplicatedPartitions | > 0 for | Replicas are missing. Tolerates 1 more failure before partition goes offline. |
OfflinePartitionsCount | kafka.controller:type=KafkaController,name=OfflinePartitionsCount | > 0 (Immediate) | CRITICAL OUTAGE! No leader exists; reads and writes are blocked. |
UnderMinIsrPartitionCount | kafka.server:type=ReplicaManager,name=UnderMinIsrPartitionCount | > 0 (Immediate) | ISR size is below min.insync.replicas. Producers with acks=all will fail! |
3. Metric 2: Consumer Group Lag (records-lag-max)
Consumer Lag measures the delta between the highest offset committed to a partition by producers (Log End Offset - LEO) and the latest offset processed by a consumer group (Current Offset):
JMX MBean & Prometheus Export:
- Metric:
kafka.consumer:type=consumer-fetch-manager-metrics,client-id={client-id},name=records-lag-max - Alert Rule: If
records-lag-max > 50000ORrate(consumer_lag)[15m] > 0(lag is monotonically increasing, meaning consumer cannot keep up with ingress rate).
4. Metric 3: Broker Request Handler Thread Utilization
Kafka brokers process client requests across two thread pools:
- Network Processor Threads (
num.network.threads): Read/write bytes to non-blocking NIO sockets. - Request Handler Threads (
num.io.threads): ProcessProduceandFetchrequests against the local PageCache/disk.
RequestHandlerAvgIdlePercent:
- MBean:
kafka.server:type=KafkaRequestHandlerPool,name=RequestHandlerAvgIdlePercent - Health Benchmark: Should remain ( idle) under peak load.
- Alert Threshold: If
RequestHandlerAvgIdlePercent < 0.20( idle), the broker's CPU is saturated handling socket requests. New connections will experience timeout spikes. Scale out broker nodes immediately.
5. Complete Production Prometheus Alerting Rules
6. Summary Checklist
- Export JMX Metrics using Prometheus JMX Exporter (
jmx_prometheus_javaagent) on all broker JVM instances. - Set P0 PagerDuty alarms on
OfflinePartitionsCount > 0andUnderReplicatedPartitions > 0. - Deploy Burr or Kafka Exporter to monitor consumer group lag externally without burdening client application runtimes.