Enforce SLAs and Alert When Workflows Miss Performance Targets
For the complete documentation index, see llms.txt. For a full content snapshot, see llms-full.txt. Append.mdto anykestra.io/docs/*URL for plain Markdown.
SLAs define time or assertion-based checks on flow executions and trigger corrective actions when those checks fail.
Use the sla property at the root of a flow to declare one or more SLA checks. Each SLA specifies a type, the condition to check, and a behavior to trigger when the condition is violated.
SLA types
Kestra supports two SLA types:
- MAX_DURATION — the maximum allowed execution duration before the SLA is breached
- EXECUTION_ASSERTION — a Pebble expression that must evaluate to
trueduring execution. If it evaluates tofalse, the SLA is breached.
MAX_DURATION
The following SLA cancels an execution if it runs for more than 8 hours:
id: sla_examplenamespace: company.team
sla: - id: maxDuration type: MAX_DURATION duration: PT8H behavior: CANCEL labels: sla: miss reason: durationExceeded
tasks: - id: punctual type: io.kestra.plugin.core.log.Log message: Workflow started, monitoring SLA compliance
- id: sleepyhead type: io.kestra.plugin.core.flow.Sleep duration: PT9H
- id: never_executed_task type: io.kestra.plugin.core.log.Log message: This task will never start because the SLA was breachedEXECUTION_ASSERTION
EXECUTION_ASSERTION evaluates a Pebble expression against the execution at runtime. The following SLA fails the execution if mytask does not return expected output:
id: sla_demonamespace: company.team
sla: - id: assert_output type: EXECUTION_ASSERTION assert: "{{ outputs.mytask.value == 'expected output' }}" behavior: FAIL labels: sla: miss reason: outputMismatch
tasks: - id: mytask type: io.kestra.plugin.core.debug.Return format: expected outputSLA behavior
The behavior property controls what happens when the SLA is breached:
- CANCEL — cancels the execution
- FAIL — fails the execution
- NONE — logs a message without stopping the execution
Each SLA can also set labels on the breached execution, making it easy to filter affected executions or trigger follow-up actions.
Alerts on SLA breaches
Use a Flow trigger on the sla: miss label to send an alert whenever an SLA is breached:
id: sla_miss_alertnamespace: system
tasks: - id: send_alert type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook url: "{{ secret('SLACK_WEBHOOK') }}" messageText: "SLA breached for flow `{{ trigger.namespace }}.{{ trigger.flowId }}` with ID `{{ trigger.executionId }}`"
triggers: - id: alert_on_failure type: io.kestra.plugin.core.trigger.Flow dependsOn: - labels: sla: miss states: [FAILED, WARNING, CANCELLED]Was this page helpful?