Webhook icon
Schedule icon
WorkingDirectory icon
Commands icon
Docker icon
Script icon
If icon
SlackIncomingWebhook icon
Log icon

Alert When Streaming Windows Ship With Late or Missing Rows

Grade expected against received rows for every streaming window, flag windows below your completeness SLA, and alert Slack with the worst gap.

Categories
Data

How it works

  1. post_window_stats (io.kestra.plugin.core.trigger.Webhook, keyed) accepts the arrival stats POST from the streaming collector or the watermark monitor. hourly_arrival_sweep (io.kestra.plugin.core.trigger.Schedule) ships disabled: true as a fallback net once an operator switches it on.
  2. arrival_workspace (io.kestra.plugin.core.flow.WorkingDirectory) opens one shared directory so the writer and the grader read the same file, because default tasks are stateless and the temp directory is purged when a task completes.
  3. write_arrival_stats (io.kestra.plugin.scripts.shell.Commands on the io.kestra.plugin.scripts.runner.docker.Docker runner, image python:3.12-slim) writes the posted body, or the arrival_stats input default on manual runs, into window_arrivals.json with a quoted heredoc.
  4. grade_completeness (io.kestra.plugin.scripts.python.Script on python:3.12-slim) computes the received share of every window against min_completeness_pct, collects the windows below the floor, sums the rows that missed the watermark, and emits the verdict through the outputs protocol.
  5. check_sla (io.kestra.plugin.core.flow.If) branches on the verdict. A late window runs notify_late_arrival, the Slack incoming webhook that names the incomplete windows, the worst share, and the missing rows. An unreadable payload runs check_grade_error, a second If whose alert_unreadable_stats branch pages Slack so a broken feed never reads as a clean window, and only a fully complete window reaches log_within_sla.
  6. The errors block alerts Slack whenever the flow itself breaks, because a dead grader must never look like a perfect window.

What you get

  • A completeness grade for every window in the posted batch, with the exact rows that never arrived before the watermark.
  • A Slack alert that names the late windows, the worst received share, and the total missing rows the moment the batch is graded.
  • A separate unreadable payload branch, so a malformed POST escalates instead of quietly passing as zero incomplete windows.
  • Gateable outputs, verdict, incomplete_windows, worst_pct, total_missing_rows, and windows_checked for any parent pipeline that wants to block its publish step.
  • A dated execution history that doubles as watermark evidence for the platform team.

Who it's for

  • Streaming platform teams that publish windows downstream and want proof each window was complete before consumers read it.
  • Data engineers who currently discover missing rows only after a dashboard or a retrain absorbs them.
  • On-call engineers who want late data paged to the channel with the window names already attached.

Why orchestrate this with Kestra

A completeness check is one division, but an alert needs the state around it, a keyed webhook for the collector, a hermetic Python runtime pinned in the flow file, a threshold that separates escalation from the all-clear, and an execution record proving the grade ran for that exact batch. Kestra supplies all of that declaratively, with Slack routing, an error handler, and a branch structure that any scheduler already understands. A cron job that greps logs gives you none of that, it only helps the people who remember to look.

Prerequisites

  • A worker with Docker access, both the writer and the grader run in python:3.12-slim.
  • A Slack incoming webhook for the late-arrival alert, unreadable payload pages, and failure alerts.
  • A collector that POSTs arrival stats shaped as a pipeline name and a windows array carrying window_start, expected_rows, and received_rows per window.

Secrets

  • LATE_ARRIVAL_WEBHOOK_KEY: key segment guarding the webhook URL, anyone holding it can trigger a grade.
  • SLACK_WEBHOOK_URL: Slack incoming webhook URL used for the late-arrival alert, the unreadable payload page, and failures.

Quick start

  1. Add the secrets above to your Kestra namespace.
  2. Run the flow once with the default inputs and confirm window_arrivals.json lands in the workspace and the outputs carry verdict, worst_pct, and windows_checked.
  3. Lower one window's received_rows in arrival_stats below the floor, re-run, and watch verdict flip to late_arrival with that window named in incomplete_windows.
  4. Point the collector at /api/v1/{tenant}/executions/webhook/{namespace}/late-arrival-data-alert/{LATE_ARRIVAL_WEBHOOK_KEY} once its POST body matches the stats shape.

How to extend

  • Fan the grade out over many pipelines with a Subflow per pipeline and aggregate the verdicts in a parent flow.
  • Block the publish step by having the parent flow read verdict and stop on late_arrival instead of only alerting.
  • Replace the writer with a io.kestra.plugin.git.Clone of a stats repository when the collector publishes files instead of POSTing JSON.
  • Archive each graded batch to object storage with io.kestra.plugin.aws.s3.Upload so every window keeps its arrival evidence.
  • Walk the per-window rows with io.kestra.plugin.core.flow.Loop when you want one log line or one ticket per late window.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.