New to Kestra?
Use blueprints to kickstart your first workflows.
Ingest failed dbt tests, diagnose join fan-outs and null anomalies with Gemini AI, and generate SQL remediation briefs automatically.
Data transformations orchestrated with dbt rely on data tests (unique, not_null, relationships, and custom singular assertions) to ensure dimensional integrity before downstream BI dashboards refresh. However, when nightly batch runs fail with cryptic errors (such as 14 records returned where count > 1), on-call analytics engineers face significant toil.
Engineers must manually copy compiled SQL queries from target folders, trace macro expansions, inspect database catalogs, and determine whether the duplication stemmed from a join fan-out, unhandled null keys, or upstream schema drift.
This blueprint automates dbt failure triage. When a test fails in dbt Core or dbt Cloud, webhook integration triggers Kestra with the failed test context. An AI agent powered by Google Gemini analyzes the compiled test query and upstream transformation logic, determines the exact failure mechanism (e.g. 1-to-many payment relationship inflating order rows), categorizes severity, and generates an executable SQL remediation diff. High-severity failures immediately dispatch an executive triage card to Slack with actionable remediation steps.
diagnose_dbt_failure (ai.agent.AIAgent): Ingests the failing model name, test query, and upstream transformation SQL, using gemini-2.5-flash with a strict JSON schema to diagnose the failure mechanism, evaluate BI impact, and formulate corrected SQL.render_remediation_brief (scripts.python.Script): Transforms the diagnosis into a downloadable dbt-remediation-brief.md markdown report containing root cause explanations and ready-to-apply SQL code blocks.triage_routing_gate (core.flow.If):#analytics-alerts-urgent in Slack with the diagnosis summary and a direct link to the remediation artifact.#data-team-feed for routine sprint review.alert_on_failure (errors block): Catches unexpected script execution errors and notifies the analytics operations team.disabled: true by default) plus an authenticated Webhook trigger for CI/CD and dbt Cloud failure webhooks.Writing custom notification webhooks inside dbt packages or shell scripts creates brittle pipelines without persistent artifacts or AI capabilities. Kestra provides declarative DAG orchestration, secure API key management, native Python execution, and structured AI agent tasks for automated triage.
gemini-2.5-flash.GEMINI_API_KEY: API key for Google Gemini model inference.SLACK_WEBHOOK_URL: Slack Incoming Webhook URL for analytics alert channels.WEBHOOK_KEY: Authentication secret for event-driven webhook invocation.GEMINI_API_KEY, SLACK_WEBHOOK_URL, and WEBHOOK_KEY in your Kestra namespace secrets.dbt-remediation-brief.md from the Outputs tab and review the Slack card.run_results.json and manifest.json directly from AWS S3, Google Cloud Storage, or the dbt Cloud Administrative API.triage_routing_gate to automatically open a bug issue with the recommended SQL fix attached.