Fail icon
SlackIncomingWebhook icon

Error Handling & Observability, Send Detailed Failure Context to Slack

Send detailed Slack alerts on Kestra task failures using errorLogs(). An error-handling and observability blueprint for actionable failure context.

Categories
CoreInfrastructure
id: error-logs
namespace: company.team

tasks:
  - id: fail
    type: io.kestra.plugin.core.execution.Fail
    errorMessage: Something went wrong, make sure to fix it asap!

errors:
  - id: slack
    type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
    url: "{{ secret('SLACK_WEBHOOK') }}"
    messageText: "Failure alert for flow `{{ flow.namespace }}.{{ flow.id }}` with
      ID `{{ execution.id }}`. Here is a bit more context about why the
      execution failed: `{{ errorLogs()[0]['message'] }}`"

Turn silent pipeline failures into actionable Slack alerts. This blueprint shows the Kestra error-handling pattern: when any task in a flow fails, an errors: handler fires automatically and posts a Slack message that includes the flow namespace, the flow id, the execution id, and the actual underlying error message captured with the errorLogs() function. Instead of a generic "execution failed" ping, your on-call channel sees exactly why the run broke, cutting troubleshooting and mean-time-to-resolution.

How it works

  1. The main task fail (io.kestra.plugin.core.execution.Fail) intentionally raises an error with errorMessage set, simulating a real task failure so you can see the alerting path end to end.
  2. The failure triggers the errors: block, which runs the slack task (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) only when the flow enters an errored state.
  3. The slack task posts to your channel via an incoming webhook URL stored as a secret, building messageText from execution metadata ({{ flow.namespace }}, {{ flow.id }}, {{ execution.id }}) plus the first captured error via {{ errorLogs()[0]['message'] }}.

What you get

  • Automatic Slack notifications on any task failure, no manual try/catch.
  • The real error message inline, not just a "something failed" alert.
  • Execution context (namespace, flow, execution id) for fast triage.
  • A reusable error-handling template you can drop into any flow.

Who it's for

  • Data and platform engineers who run production pipelines.
  • On-call and SRE teams that need precise failure context in chat.
  • Anyone standardizing observability and incident response across flows.

Why orchestrate this with Kestra

Kestra's declarative YAML errors: block gives you event-driven alerting that fires the moment an execution fails, with no polling and no glue code. You get automatic retries, full execution lineage, and templated access to logs and metadata through Pebble expressions like errorLogs(). A webhook or a Slack app alone cannot watch your jobs, know which task failed, or extract the error text. Kestra closes that gap by tying the alert directly to the orchestration layer that produced the failure.

Prerequisites

  • A running Kestra instance.
  • A Slack incoming webhook for the target channel.

Secrets

  • SLACK_WEBHOOK: the Slack incoming webhook URL used to post the alert.

Quick start

  1. Create a Slack incoming webhook and copy its URL.
  2. Add it to Kestra as the secret SLACK_WEBHOOK.
  3. Add this blueprint to your namespace and run it.
  4. Watch the forced failure trigger a Slack message with the error details.

How to extend

  • Replace the fail task with your real pipeline tasks and keep the errors: block as a global failure handler.
  • Enrich messageText with more variables, links to the execution UI, or @mentions for the right on-call owner.
  • Swap or add channels by routing to multiple webhook secrets.
  • Combine with retries and timeouts so Slack only fires after retries exhaust.

Links

Orchestrate with Kestra
Orchestrate Slack with Kestra
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.