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 |
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 |
3. Tracking Message Rate
| Metric | Description | Detail |
|---|---|---|
| MessagesInPerSec | Records/sec | Throughput |
| Trend | Capacity planning | Growth |
| Spikes | Traffic anomalies | Alert |
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 |
5. Checking Under-Replicated Partitions
| Metric | Description | Healthy |
|---|---|---|
| UnderReplicatedPartitions | Replicas behind | 0 |
| Non-Zero | Broker/disk/network issue | Investigate |
| Critical | Risk to durability | Page |
6. Monitoring ISR Shrink/Expand
| Metric | Description | Detail |
|---|---|---|
| IsrShrinksPerSec | Replicas falling out | Lag/failure |
| IsrExpandsPerSec | Replicas catching up | Recovery |
| Frequent | Instability signal | Tune |
7. Tracking Leader Election Rate
| Metric | Description | Detail |
|---|---|---|
| LeaderElectionRate AndTimeMs |
Election frequency | Should be rare |
| Unclean | UncleanLeaderElections | =0 desired |
| Spikes | Broker churn | Investigate |
8. Monitoring Log Flush Latency
| Metric | Description | Detail |
|---|---|---|
| LogFlushRate AndTimeMs |
fsync duration | Disk health |
| High | Slow disk | Bottleneck |
| Percentiles | p99 matters | Tail latency |
9. Checking Network Processor Idle
| Metric | Description | Healthy |
|---|---|---|
| NetworkProcessor AvgIdlePercent |
Network thread headroom | >0.3 |
| Low | Network-bound | Add threads |
| 0 | Saturated | Critical |
10. Monitoring Request Queue Size
| Metric | Description | Detail |
|---|---|---|
| RequestQueueSize | Pending requests | Backlog |
| ResponseQueueSize | Pending responses | Backlog |
| Growing | Handler saturation | Scale IO threads |