New to Kestra?
Use blueprints to kickstart your first workflows.
Kestra flow that listens for executions cancelled by a MAX_DURATION SLA using a Flow trigger with state and label preconditions, then emits an automated root-cause report with fix and replay steps.
When an execution blows its SLA, the slow part is rarely the fix; it is the triage. This Kestra blueprint automates that triage: a Flow trigger watches a specific flow for executions that ended CANCELLED with an sla: breach label, and the instant one appears it produces a root-cause report naming the offending task, the reason, and the exact replay procedure. Failure analysis becomes an orchestrated reaction instead of a Slack thread.
on_recovery_loop_sla_breach trigger (io.kestra.plugin.core.trigger.Flow) uses preconditions to match executions of company.team.self-healing-recovery-loop that reached the CANCELLED state and carry the label sla: breach. That label is stamped by the source flow's own MAX_DURATION SLA definition, so only genuine SLA cancellations fire the trigger, not manual kills.log_rca task (io.kestra.plugin.core.log.Log) renders the report using trigger context: {{ trigger.namespace }}, {{ trigger.flowId }}, {{ trigger.executionId }}, and {{ trigger.state }}. In this demo pairing, the root cause is known by construction (the upstream guaranteed_failure_sla task sleeps 60 seconds against a 90-second SLA), so the report can point at the exact line and prescribe the fix: change sleep 60 to sleep 5 and replay the failed task.Most schedulers can alert that something failed; very few can orchestrate what happens next. Kestra's Flow trigger turns execution state into an event source, and label preconditions let SLA policy (defined in the source flow) drive downstream automation without any glue code. Because the RCA is itself a flow, it can grow from a log line into a pipeline: query the failed execution via the API, attach logs, open a ticket, and notify the owning team, all version-controlled in YAML.
self-healing-recovery-loop deployed in company.team (see Links), including its sla block that applies the sla: breach label with behavior: CANCEL.No secrets are required for the logging version. If you extend the report to notify or file tickets, store credentials such as SLACK_WEBHOOK_URL or JIRA_API_TOKEN as secrets and reference them with {{ secret('NAME') }}.
company.team.self-healing-recovery-loop; after about 90 seconds its SLA cancels the run and labels it sla: breach.log_rca output to read the report.Log with io.kestra.plugin.notifications.slack.SlackExecution or a PagerDuty/Opsgenie task for real alerting.{{ trigger.executionId }} for traceability.preconditions to a whole namespace of flows and route on {{ trigger.flowId }} inside the report.