Design a strategy for monitoring and alerting in a Kafka ecosystem.
Instruction: Outline a comprehensive strategy for monitoring key metrics within a Kafka ecosystem and setting up alerting mechanisms. Include which metrics would be most important to monitor and how these metrics can be used to preempt and diagnose issues.
Updated
Official answer
Start with an end-to-end service objective: for example, how quickly an accepted order must become a completed downstream update. Broker health alone does not show whether that work finished.
Collect broker, controller, producer, consumer and application metrics. Useful signals include offline partitions, under-replicated partitions, ISR changes, controller-quorum health, disk runway, request latency/errors, throttling, producer failures, consumer rebalances and downstream completion latency. Correlate these with CPU, garbage collection, network and storage saturation.
Distinguish consumer position from committed progress. A consumer's records-lag-max uses its current offset, not its committed offset. Neither proves an external side effect completed. An offset distance is not elapsed time and, with gaps or transactional records, need not equal the count of user records awaiting work. Track event age and completion checkpoints separately.
Use secured JMX/exporters and a time-series system such as Prometheus with dashboards in Grafana. Restrict monitoring access and sensitive labels; Kafka's remote JMX needs explicit security configuration when enabled.
Define sustained, workload-specific thresholds and route alerts to an owner with a runbook. Page on user impact or imminent loss of recoverable history, rather than every brief fluctuation. Include missing telemetry and stale heartbeats. Test alerts with a stopped consumer, failed broker and unavailable downstream service; verify detection, escalation and recovery. Record results instead of claiming an unmeasured reliability improvement.
Kafka monitoring metrics and JMX security, consumer progress semantics