Script icon
If icon
SquadcastIncomingWebhook icon
Log icon
DiscordIncomingWebhook icon

Open a Squadcast Incident on Data Quality Breach

Treat bad data as an incident. Kestra profiles a batch, computes the null rate, and pages Squadcast with rates and row counts when the threshold is breached.

Categories
BusinessInfrastructure

Data quality failures usually travel by email, a report someone reads next Tuesday, long after the bad batch reached every dashboard downstream. This blueprint treats a breached quality threshold the way infrastructure teams treat a down host, it pages. A Python task profiles the latest batch and emits the null rate of a key column through Kestra's output protocol; an If gate compares it to the max_null_rate input; a breach opens a Squadcast incident through io.kestra.plugin.squadcast.SquadcastIncomingWebhook carrying the measured rate, the threshold, and the affected row counts.

How it works

  1. profile_orders (io.kestra.plugin.scripts.python.Script) computes null_count, row_count, and null_rate over an inline sample batch, then prints them through the ::{"outputs": {...}}:: protocol, making them available as {{ outputs.profile_orders.vars.* }}. In production the script reads the batch your pipeline just loaded.
  2. quality_gate (io.kestra.plugin.core.flow.If) branches on null_rate > inputs.max_null_rate.
  3. On breach, page_quality_incident posts a JSON payload with status: trigger, the execution id as event_id, and tags naming the check and the column, and a description with the exact numbers, so on-call sees blast radius before opening Kestra.
  4. On a clean profile, log_quality_ok records the rate, building a quality history inside the execution log.
  5. The errors block reports to Discord when the gate itself fails, because an unprofiled batch is indistinguishable from a clean one.

What you get

  • Quality breaches escalated with acknowledgment and on-call ownership instead of an inbox.
  • Incidents that carry the evidence, measured rate, threshold, null and row counts, check and column tags.
  • A reusable gate shape, swap the metric for duplicates, schema drift, or volume anomalies without touching the paging logic.
  • A fallback channel when the gate itself cannot run.

Who it's for

  • Data platform teams whose freshness and quality alerts currently go to email distribution lists.
  • Analytics engineers who want quality checks attached to the pipeline run that produced the data.
  • On-call rotations extending their incident process to data incidents.

Why orchestrate this with Kestra

A quality gate needs to run right after the load, see the same data, branch on the result, and page with context. Kestra provides all four in one flow, the Python task emits metrics as first-class outputs, the If task routes on them, and the Squadcast task turns a number into an incident, with the whole decision auditable in the execution history.

Prerequisites

  • A Squadcast Incoming Webhook (API) integration on the target service.
  • A Discord incoming webhook for the pager-failure fallback.
  • Python task execution available on your workers (the default container runner works as-is).

Secrets

  • SQUADCAST_WEBHOOK_URL: the full Squadcast incoming webhook endpoint, including its token.
  • DISCORD_WEBHOOK_URL: Discord incoming webhook URL for the fallback alert.

Quick start

  1. Add both secrets to your namespace.
  2. Execute with defaults, the sample batch has a 0.25 null rate against a 0.1 threshold, so a Squadcast incident opens immediately and shows the numbers.
  3. Set max_null_rate to 0.5 and rerun to see the quiet passing path.
  4. Point profile_orders at your real batch, for example by reading the table your load task just wrote, and route the Squadcast service to the team that owns the dataset.

How to extend

  • Replace the inline sample with a query against your warehouse and profile the rows the last execution loaded.
  • Emit several metrics from one profile run and page on the worst offender, keeping a single gate per dataset.
  • Chain the gate after an ingestion flow with a flow trigger so every load is profiled automatically.
  • Auto-resolve the incident when the next batch passes, reusing the event id pattern from the incident resolve sync blueprint.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.