Home
ArenaGraphSignalTopics
/Apache Kafka and Event-Driven Systems: Building Real-Time Streaming Pipelines
Chapter 10 • Module 1 8 min breakdown +15 XP Module

Critical Kafka Metrics to Monitor in Production: Consumer Lag, ISRs, and JMX

From Track:Apache Kafka and Event-Driven Systems: Building Real-Time Streaming PipelinesEvent-Driven Architecture & Distributed Systems

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

Interactive Blueprint
Rendering diagram...

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.

Interactive Blueprint
Rendering diagram...

Key JMX Metrics & Thresholds:

Metric NameJMX MBean PathCritical ThresholdMeaning & Action
UnderReplicatedPartitionskafka.server:type=ReplicaManager,name=UnderReplicatedPartitions> 0 for Replicas are missing. Tolerates 1 more failure before partition goes offline.
OfflinePartitionsCountkafka.controller:type=KafkaController,name=OfflinePartitionsCount> 0 (Immediate)CRITICAL OUTAGE! No leader exists; reads and writes are blocked.
UnderMinIsrPartitionCountkafka.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):

Interactive Blueprint
Rendering diagram...

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 > 50000 OR rate(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:

  1. Network Processor Threads (num.network.threads): Read/write bytes to non-blocking NIO sockets.
  2. Request Handler Threads (num.io.threads): Process Produce and Fetch requests 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

yaml
Loading code editor...

6. Summary Checklist

  • Export JMX Metrics using Prometheus JMX Exporter (jmx_prometheus_javaagent) on all broker JVM instances.
  • Set P0 PagerDuty alarms on OfflinePartitionsCount > 0 and UnderReplicatedPartitions > 0.
  • Deploy Burr or Kafka Exporter to monitor consumer group lag externally without burdening client application runtimes.
Milestone Verification

Ready for the next lesson?

Mark this module complete to record verified progress and earn +15 XP toward your architect profile.

Critical Kafka Metrics to Monitor in Production: Consumer Lag, ISRs, and JMX | InitNode | InitNode