DbtCLI icon
Docker icon
SlackIncomingWebhook icon
Schedule icon

Scheduled dbt Core Run with Failure Alerting

Schedule dbt Core models and tests with Kestra, post success to Slack, and fire an automatic failure alert when a run or test breaks.

Categories
Data

Run dbt Core models and tests on a fixed schedule and make data quality failures impossible to miss. This blueprint orchestrates a nightly dbt Core pipeline that installs project dependencies, builds your models, runs your tests, and posts the result to Slack. If any step fails, an error handler fires a separate failure alert so broken transformations and failing tests surface the same night they happen, instead of being discovered by a stakeholder the next morning.

How it works

  1. The nightly_run trigger (io.kestra.plugin.core.trigger.Schedule, cron 0 2 * * *, shipped disabled) starts the flow on a cadence.
  2. build_models runs io.kestra.plugin.dbt.cli.DbtCLI inside a Docker task runner using the ghcr.io/kestra-io/dbt-duckdb image, with namespaceFiles enabled to load your dbt project, then executes dbt deps and dbt run.
  3. test_models runs DbtCLI again with the same image and namespaceFiles to execute dbt test and validate data quality.
  4. notify_success posts a confirmation to Slack via io.kestra.plugin.slack.notifications.SlackIncomingWebhook.
  5. If any task fails, the notify_failure error handler sends a SlackIncomingWebhook alert tagged with the failing execution.id.

What you get

  • A scheduled, containerized dbt Core run with dependencies installed each time.
  • Automatic data quality validation through dbt test.
  • A success ping and a distinct failure alert in Slack, both referencing the execution.
  • A self-contained pattern that works with the bundled DuckDB image out of the box.

Who it's for

  • Analytics engineers maintaining dbt Core projects.
  • Data teams that need nightly transformations with proactive failure alerts.
  • Platform engineers consolidating dbt scheduling and observability in one orchestrator.

Why orchestrate this with Kestra

dbt itself has no scheduler, no retry logic, and no native alerting. Kestra adds event and schedule triggers, automatic retries, full execution lineage and logs, and declarative YAML you can version control. The errors block guarantees that a failed dbt run or dbt test always produces an alert, something a bare dbt invocation in cron cannot do.

Prerequisites

Secrets

  • SLACK_WEBHOOK_URL: Slack incoming webhook URL used for both the success and failure notifications.

You also need your dbt project (including profiles.yml) uploaded as namespace files so namespaceFiles can load it into the task working directory.

Quick start

  1. Set SLACK_WEBHOOK_URL in your Kestra namespace.
  2. Upload your dbt project to the namespace so namespaceFiles can load it.
  3. Enable the nightly_run schedule (it ships disabled) to run at 02:00 daily.

How to extend

  • Swap ghcr.io/kestra-io/dbt-duckdb for the adapter image matching your warehouse (Snowflake, BigQuery, Postgres, and so on).
  • Adjust the cron to your SLA, or replace the schedule with a flow or event trigger.
  • Add retry to the dbt tasks to recover from transient warehouse errors.
  • Route the failure alert to PagerDuty or email, or attach dbt run output to the Slack message.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.