Schedule icon
Commands icon
Docker icon
Get icon
Script icon
If icon
Log icon
SlackIncomingWebhook icon
Set icon

Kafka KRaft Metadata Quorum Health Sentinel

Monitor Kafka KRaft voters, metadata replication lag and repeated controller elections, with stateful Kestra alerts before control-plane failure.

Categories
Infrastructure

Kafka's KRaft controllers hold the metadata that makes topic creation, partition leadership and broker registration possible. A quorum can keep serving while one controller is stale or absent, leaving the cluster one fault away from losing its control plane. This blueprint runs Kafka's own read-only quorum tools, applies explicit safety invariants and remembers leader observations between executions.

How it works

  1. The disabled five-minute schedule starts the sentinel after operators have verified connectivity and alerting with a manual execution.
  2. inspect_quorum runs kafka-metadata-quorum.sh describe --status and describe --replication in the official Kafka image. It optionally writes secret-backed SASL or TLS properties to a mode-600 file and retains both raw responses as execution artifacts.
  3. load_previous_observation reads the last snapshot from Kestra's namespace KV store. A missing value is valid on the first execution.
  4. assess_quorum parses the real CLI responses and checks for an unelected or inconsistent leader, too few configured voters, missing expected controller IDs, voters without replication rows, excessive record lag, excessive catch-up time and repeated sampled leader changes.
  5. route_result logs healthy executions quietly. A warning or critical result writes the structured findings to the execution log and sends one consolidated Slack alert.
  6. remember_observation stores the current leader, epoch, voter set and lag metrics for the next execution. Inspection failures follow a separate error alert because unknown quorum health must not look healthy.

What you get

  • HEALTHY, WARNING or CRITICAL as a reusable flow output.
  • Raw status.txt and replication.txt artifacts from Kafka's own CLI for incident evidence.
  • Structured findings that identify the failed invariant rather than emitting a generic cluster-down alarm.
  • Stateful detection of repeated sampled leader changes without deploying another always-on monitoring service.
  • Read-only operation: the flow never changes quorum membership, elects a leader or writes Kafka metadata.

Who it's for

  • Kafka platform teams operating KRaft clusters without ZooKeeper.
  • SREs responsible for controller availability during broker maintenance and upgrades.
  • Teams that want auditable control-plane checks alongside Kestra-managed data pipelines.

Why orchestrate this with Kestra

A cron script can capture one quorum snapshot, but it has no durable execution history, secret abstraction, branching or prior-run state. Kestra keeps the raw Kafka evidence, threshold decision, notification and previous leader observation in one declarative flow. The resulting status and findings can also gate maintenance or deployment flows.

Prerequisites

  • A Kafka cluster running in KRaft mode and reachable from Kestra's Docker task runner.
  • Kafka credentials with permission to describe cluster metadata.
  • Docker task-runner access to pull the configured Kafka and Python images, plus a Docker network that can resolve the broker addresses.
  • A Slack incoming webhook before enabling the schedule.

Secrets

  • SLACK_WEBHOOK_URL: Slack incoming webhook used for findings and inspection failures.
  • Provide SASL or TLS configuration through the client_properties secret input. For scheduled use, replace its default with an expression such as {{ secret('KAFKA_CLIENT_PROPERTIES') }} in your imported copy.

Quick start

  1. Import the blueprint, set bootstrap_servers to at least one reachable broker, and set docker_network_mode to the Docker network that can resolve it.
  2. For secured Kafka, supply complete client properties through client_properties; never paste credentials into the YAML.
  3. Set expected_voter_ids to the controller IDs from the cluster's intended quorum configuration. Leave it empty only when checking the currently configured set is sufficient.
  4. Run the flow manually. Confirm status is HEALTHY and inspect the two CLI artifacts.
  5. Test the alert path with a deliberately impossible minimum_voter_count, then restore the correct value and enable the schedule.

How to extend

  • Add a maintenance-calendar check so planned controller restarts suppress notifications without suppressing evidence collection.
  • Create a ticket only when a finding persists across several runs while continuing to send critical no-leader alerts immediately.
  • Run one subflow per Kafka environment and aggregate the snapshots into a fleet-wide controller health dashboard.
  • Feed the status output into an upgrade flow so controller rollouts stop when the quorum is already degraded.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.