Request icon
OutputValues icon
If icon
SlackIncomingWebhook icon
Pause icon
Loop icon
Sleep icon
Log icon
Schedule icon

Triage and Replay Failed Kestra Executions

Find failed Kestra executions, send details to Slack, and safely restart them behind an approval gate.

Categories
CoreInfrastructure

When a batch of workflows fails overnight from a network drop or a downstream API timeout, an alert tells you something broke, but someone still has to open the UI and restart each run. If thirty runs failed, doing that by hand is slow and easy to lose track of.

This flow scans a namespace for failed executions, lists them in a dry run, and behind a Pause approval restarts them one by one through Kestra's restart API. After restarting, it queries the API again to check which runs cleared and which failed again.

Safety

Restarting workflows has side effects, so this flow includes safeguards:

  • Scope: Only executions in the chosen namespace are considered.
  • Self-exclusion: It never restarts itself or any run of this flow.
  • Ignored flows: exclude_flows lists flows that should not be automatically restarted.
  • Batch limit: max_replays caps how many executions are restarted in a single run.
  • Two flags required: Replay only runs when auto_replay is true and dry_run is false.
  • Human approval: A Pause task waits for an operator to confirm before any restart call runs.
  • Rate limit: The Loop uses concurrencyLimit: 1 so executions restart one by one.

How it works

  1. query_failed_executions (io.kestra.plugin.core.http.Request) calls GET /api/v1/executions/search with filters[state][EQUALS]=FAILED and filters[namespace][EQUALS].
  2. triage_failures (io.kestra.plugin.core.output.OutputValues) filters out self-runs and flows listed in exclude_flows, then caps the list to max_replays.
  3. check_candidate_count (io.kestra.plugin.core.flow.If) branches: logs clean if no runs failed, or sends a Slack alert with the failing executions and start times.
  4. evaluate_replay_permission (io.kestra.plugin.core.flow.If) checks whether auto_replay is true and dry_run is false.
  5. approve_replay (io.kestra.plugin.core.flow.Pause) waits for confirmation before issuing restarts.
  6. restart_candidates (io.kestra.plugin.core.flow.Loop) calls POST /api/v1/executions/{id}/actions/restart for each execution one at a time.
  7. settling_delay (io.kestra.plugin.core.flow.Sleep) waits 15 seconds to give restarted executions time to initialize.
  8. verify_post_restart_states re-queries the API and notify_resolution_slack posts the final count of remaining failures.

What you get

  • A list of failed executions in the namespace without opening each flow page.
  • A Slack summary showing which flows failed and when they started.
  • Safe-by-default execution that changes nothing unless both flags are set and approved.
  • A readback check that shows whether the restarted runs succeeded or stayed failed.

Who it's for

  • Platform Engineers and SRE teams managing shared Kestra clusters.
  • Data Operations teams monitoring nightly ETL and batch orchestration pipelines.
  • Teams that want to restart transient failed executions without manually opening every run in the UI.

Why orchestrate this with Kestra

Running this as a Kestra flow means you don't need external monitoring scripts or cron jobs to check your cluster. Native HTTP tasks and Pause gates handle the API calls and human approval directly.

Pitfalls

  • Deterministic bugs: An execution that failed from a syntax error or a bad schema will fail again when restarted. Use exclude_flows to keep those out of the replay queue.
  • Worker load: Restarting heavy data pipelines all at once can spike worker memory. The flow runs restarts sequentially (concurrencyLimit: 1) and caps batch size with max_replays.
  • Authentication: If your cluster requires authentication, pass your token in api_token so the HTTP requests include the authorization header.

Prerequisites

  • Running Kestra 2.0+ cluster with accessible webserver API.
  • Slack incoming webhook URL for notifications.

Secrets

  • SLACK_WEBHOOK_URL: Webhook URL for posting triage alerts and resolution summaries.

Quick start

  1. Deploy the blueprint into your administrative namespace (e.g., company.team).
  2. Run a manual execution with dry_run: true to discover failed executions without triggering restarts.
  3. Review the Slack triage alert to verify identified candidate executions.
  4. When ready to restart, execute with dry_run: false and auto_replay: true, then approve the Pause task.
  5. Enable hourly_failure_sweep for continuous automated dead-letter monitoring.

How to extend

  • Swap notify_triage_slack for Microsoft Teams or PagerDuty incident triggers.
  • Parse task run error logs with /api/v1/logs/{executionId} to distinguish network timeouts from bad input errors.
  • Add automated notifications to specific team channels based on the failed flow's namespace.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.