Schedule icon
Webhook icon
Assert icon
Query icon
Get icon
Script icon
Set icon
If icon
Log icon
Pause icon
Loop icon
Request icon
SlackIncomingWebhook icon

Apache Druid Supervisor Stalled Ingestion Auto-Reset and Recovery Guard

Audit Apache Druid streaming ingestion supervisors, persist health in KV, auto-reset wedged supervisors behind approval, and verify recovery in Kestra.

Categories
DataInfrastructure

Production real-time analytical architectures rely on Apache Druid to ingest high-velocity event streams from Apache Kafka and AWS Kinesis. In Druid, stream ingestion is orchestrated by Supervisors running on the Overlord service. Each supervisor continuously spawns indexing task workers, assigns partitions, tracks offsets, and coordinates segment handoff to Historical nodes.

During Kafka partition rebalances, poison pill records, schema mismatches, or network partitions between Druid MiddleManagers and Kafka brokers, ingestion tasks can crash repeatedly. When consecutive worker tasks fail, the supervisor transitions to UNHEALTHY_SUPERVISOR, UNHEALTHY_TASKS, or SUSPENDED state. Once wedged, the supervisor ceases to consume records from the streaming topic. Ingestion lag mounts, real-time metrics diverge from source data, and analytical queries against Druid return increasingly stale results while overall cluster metrics appear deceptive green.

This blueprint provides an automated supervisory recovery guard for Apache Druid that audits supervisor health via sys.supervisors and sys.tasks, diffs consecutive failure runs against Kestra KV store, isolates root-cause worker exceptions, safely executes authorized Overlord reset and resume operations behind an operator approval gate, verifies post-remediation recovery, and delivers structured triage reports to Slack.

How it works

  1. Pre-Flight Validation: validate_inputs (io.kestra.plugin.core.execution.Assert) validates operational parameters, ensuring accessible Druid JDBC and Overlord endpoints and valid threshold limits.
  2. Supervisor Health Audit: query_unhealthy_supervisors (io.kestra.plugin.jdbc.druid.Query) queries the Druid metadata catalog table sys.supervisors for supervisors where healthy = 0 or state is UNHEALTHY_SUPERVISOR, UNHEALTHY_TASKS, or SUSPENDED.
  3. Task Failure Triage: query_recent_failed_tasks (io.kestra.plugin.jdbc.druid.Query) queries sys.tasks for recently failed indexing tasks, extracting worker hostnames, datasource names, and error traces.
  4. Historical Health Tracking: load_previous_guard_state (io.kestra.plugin.core.kv.Get) retrieves prior execution state from Kestra KV store under druid_supervisor_stalled_guard_state.
  5. Triage & Classification: triage_supervisor_failures (io.kestra.plugin.scripts.python.Script) parses supervisor health states, correlates failed task traces, increments consecutive stall counters, and identifies supervisors that exceed stalled_runs_threshold.
  6. KV State Persistence: persist_guard_state_kv (io.kestra.plugin.core.kv.Set) stores updated health progression and stall telemetry back to Kestra KV store.
  7. Safe Remediation with Approval Gate: When dry_run is disabled and remediation is qualified:
    • The workflow pauses execution at approval_gate (io.kestra.plugin.core.flow.Pause) for operator verification.
    • Upon operator approval, remediate_supervisors (io.kestra.plugin.core.flow.Loop) iterates sequentially over each stalled supervisor:
      • Issues POST /druid/indexer/v1/supervisor/{id}/reset via io.kestra.plugin.core.http.Request to clear wedged checkpoints and restart task generation.
      • If the supervisor was in SUSPENDED state, issues POST /druid/indexer/v1/supervisor/{id}/resume to reactivate ingestion.
  8. Post-Remediation Verification: verify_supervisors_remediation re-queries sys.supervisors to verify that previously failing supervisors recovered to healthy state (healthy = 1).
  9. Incident Reporting: dispatch_slack_notification (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) sends an operational triage summary to Slack with supervisor states, stall durations, and remediation outcomes.

What you get

  • Automated detection of Apache Druid streaming supervisors trapped in unhealthy or suspended states.
  • Elimination of silent real-time ingestion freezes without manual Overlord restarts.
  • Root-cause correlation matching failed indexing worker tasks and exception stack traces to their parent supervisor.
  • Safe automated remediation issuing native Overlord reset and resume requests.
  • Operator approval gate (Pause) and dry-run simulation mode to prevent unauthorized cluster mutations.
  • Post-remediation verification proving that supervisor health is restored before closing executions.
  • Persistent historical telemetry in Kestra KV store for compliance tracking and MTTR analysis.

Who it's for

  • Real-Time Data Platform Engineers operating Apache Druid, Kafka, and Kinesis pipelines.
  • SREs and Incident Responders managing low-latency analytical data warehouses.
  • Analytics Engineers investigating real-time dashboard data freshness and silent ingestion stalls.

Why orchestrate this with Kestra

Apache Druid provides REST endpoints and system SQL tables, but does not self-heal supervisors that encounter repeated task crashes or partition offset gaps. Writing custom bash scripts with curl leaves no execution logs, lacks atomic state tracking across runs, has no approval gates, and risks uncontrolled reset loops.

Orchestrating this recovery guard with Kestra delivers a robust declarative blueprint with native Druid Avatica JDBC integration, containerized triage logic, atomic Kestra KV state tracking, interactive pause-and-resume approval mechanisms, post-action verification, and automated Slack escalation.

Prerequisites

  • Accessible Apache Druid cluster (version 0.20 or higher) with Overlord and Coordinator/Router services.
  • Streaming ingestion supervisors configured on Druid (e.g. Kafka or Kinesis).
  • Basic authentication credentials with read access to sys.supervisors and write access to /druid/indexer/v1/supervisor/*.
  • A Slack Incoming Webhook URL configured in Kestra secrets.

Secrets

  • DRUID_USER: Username for Druid Avatica JDBC and Overlord HTTP authentication.
  • DRUID_PASSWORD: Password for Druid Avatica JDBC and Overlord HTTP authentication.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL for triage and failure notifications.
  • DRUID_GUARD_WEBHOOK_KEY: Secret authentication key protecting the on-demand webhook trigger.

Quick start

  1. Configure DRUID_USER, DRUID_PASSWORD, SLACK_WEBHOOK_URL, and DRUID_GUARD_WEBHOOK_KEY in your Kestra namespace secrets.
  2. Import this blueprint and set druid_url and overlord_url to match your Druid cluster endpoints.
  3. Run a manual execution with dry_run: true to record an initial supervisor baseline and review any detected warnings.
  4. To remediate an active ingestion stall, execute with dry_run: false and approve the approval_gate pause task.
  5. Enable the hourly_supervisor_guard schedule trigger to maintain continuous automated oversight.

How to extend

  • Kafka Partition Lag Correlation: Query the Kafka AdminClient via io.kestra.plugin.kafka.ConsumerGroupDescribe to correlate Druid supervisor stalls with upstream consumer group lag.
  • Datasource Compaction Check: Add an io.kestra.plugin.jdbc.druid.Query task to trigger auto-compaction jobs once supervisor ingestion resumes.
  • PagerDuty Escalation: Integrate io.kestra.plugin.pagerduty.notifications.PagerDutyAlert when consecutive supervisor resets exceed critical limits.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.