Monitoring Broker Metrics

1. Understanding JMX Metrics

Aspect Description Detail
JMX Kafka exposes via MBeans Standard
Exporters Prometheus JMX agent Scrape
JMX_PORT Enable remote JMX Env var

Example: Enable JMX

export JMX_PORT=9999
bin/kafka-server-start.sh config/server.properties

2. Monitoring Bytes In/Out Rate

Metric Description Detail
BytesInPerSec Ingress rate Producer load
BytesOutPerSec Egress rate Consumer load
Per-Topic Tagged by topic Breakdown

Example: Bytes in

kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec

3. Tracking Message Rate

Metric Description Detail
MessagesInPerSec Records/sec Throughput
Trend Capacity planning Growth
Spikes Traffic anomalies Alert

Example: Messages in

kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec

4. Monitoring Request Metrics

Metric Description Detail
RequestsPerSec By request type Produce/Fetch
TotalTimeMs End-to-end latency Percentiles
Queue Time Waiting for handler Saturation

Example: Request latency

kafka.network:type=RequestMetrics,name=TotalTimeMs,request=Produce

5. Checking Under-Replicated Partitions

Metric Description Healthy
UnderReplicatedPartitions Replicas behind 0
Non-Zero Broker/disk/network issue Investigate
Critical Risk to durability Page

Example: URP metric

kafka.server:type=ReplicaManager,name=UnderReplicatedPartitions

6. Monitoring ISR Shrink/Expand

Metric Description Detail
IsrShrinksPerSec Replicas falling out Lag/failure
IsrExpandsPerSec Replicas catching up Recovery
Frequent Instability signal Tune

Example: ISR shrink

kafka.server:type=ReplicaManager,name=IsrShrinksPerSec

7. Tracking Leader Election Rate

Metric Description Detail
LeaderElectionRate
AndTimeMs
Election frequency Should be rare
Unclean UncleanLeaderElections =0 desired
Spikes Broker churn Investigate

Example: Unclean elections

kafka.controller:type=ControllerStats,name=UncleanLeaderElectionsPerSec

8. Monitoring Log Flush Latency

Metric Description Detail
LogFlushRate
AndTimeMs
fsync duration Disk health
High Slow disk Bottleneck
Percentiles p99 matters Tail latency

Example: Flush latency

kafka.log:type=LogFlushStats,name=LogFlushRateAndTimeMs

9. Checking Network Processor Idle

Metric Description Healthy
NetworkProcessor
AvgIdlePercent
Network thread headroom >0.3
Low Network-bound Add threads
0 Saturated Critical

Example: Network idle

kafka.network:type=SocketServer,name=NetworkProcessorAvgIdlePercent

10. Monitoring Request Queue Size

Metric Description Detail
RequestQueueSize Pending requests Backlog
ResponseQueueSize Pending responses Backlog
Growing Handler saturation Scale IO threads

Example: Request queue

kafka.network:type=RequestChannel,name=RequestQueueSize