Webhook icon
Schedule icon
Script icon
Loop icon
If icon
SlackIncomingWebhook icon
Log icon
Fail icon

Audit SNS Fanout Failures Before Subscribers Drift

Audit SNS fanout delivery metrics per subscriber, alert Slack when a failure rate crosses the threshold, and fail the run before subscribers drift.

Categories
Infrastructure

How it works

  1. on_metrics_publish (io.kestra.plugin.core.trigger.Webhook, keyed with the SNS_METRICS_WEBHOOK_KEY secret) receives the per subscriber delivery counters from your monitoring pipeline or exporter. daily_fanout_audit (io.kestra.plugin.core.trigger.Schedule, cron 0 7 * * *) is the safety net and ships disabled: true until an operator turns it on.
  2. audit_fanout (io.kestra.plugin.scripts.python.Script on python:3.12-slim) prefers the posted webhook body and falls back to a bundled example window so trial runs still demonstrate the audit. For every subscriber it computes the failure rate as failed over delivered plus failed, deliberately excluding filtered deliveries which a filter policy dropped on purpose, and flags an entry only when the rate meets failure_rate_threshold_pct and the absolute failed count meets min_failed_deliveries. The worst subscriber, the over threshold count, the window failure total and the full table are printed as a single ::{"outputs": ...}:: line.
  3. review_subscribers (io.kestra.plugin.core.flow.Loop, concurrencyLimit: 1) walks the scored rows one at a time. flag_subscriber (io.kestra.plugin.core.flow.If) branches on the per row over threshold flag, so a breaching subscriber gets its own alert_subscriber (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) with the exact counters, and a healthy subscriber is recorded by log_subscriber_ok.
  4. escalate_worst (io.kestra.plugin.core.flow.If) branches on the audit verdict. Any over threshold subscriber reaches alert_worst with the worst offender and the window totals, then fail_audit (io.kestra.plugin.core.execution.Fail) turns the run red. A clean fanout lands on log_healthy_fanout.
  5. The flow level errors handler (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) reports any failure with the execution id, because a dead auditor looks exactly like a healthy topic.

What you get

  • Per subscriber failure rates with a rate threshold and an absolute floor, so a two of three blip never pages anyone.
  • One focused Slack alert per breaching subscriber plus a worst offender escalation with the window totals.
  • Filtered deliveries tracked alongside failures, so intentional filter policy drops are visible without polluting the failure rate.
  • worst_subscriber, worst_failure_rate, total_failed, over_threshold_count and the full subscribers table as typed outputs for dashboards and incident follow-up.
  • A disabled daily audit as a second net once the webhook path is trusted.

Who it's for

  • Platform and messaging engineers responsible for SNS fanout topics feeding Lambda, SQS and email subscribers.
  • SREs who suspect subscribers are silently out of sync and need the failing endpoint named with evidence.
  • Reliability leads who want fanout delivery health gated in the same place as the rest of the pipeline checks.

Why orchestrate this with Kestra

SNS delivery failures disappear into CloudWatch unless somebody builds a dashboard and remembers to read it. Kestra gives the metrics a webhook to land on, a scorer whose rate and floor policy lives in version control, a Loop that alerts per subscriber instead of blending them, a branch that separates escalation from the all clear, and outputs a ticket or weekly report can consume. A Lambda subscribed to the delivery status queue gives you data but no gate, no history and no alert routing.

Prerequisites

  • A worker with Docker access, the scorer runs in python:3.12-slim.
  • A monitoring pipeline or exporter that can POST per subscriber delivery counters to the webhook, or rely on the bundled example window for trial runs.
  • A Slack incoming webhook for the per subscriber alerts and for failure alerts.

Secrets

  • SNS_METRICS_WEBHOOK_KEY: key segment guarding the metrics webhook URL, anyone holding it can trigger an audit run.
  • SLACK_WEBHOOK_URL: Slack incoming webhook for the subscriber alerts and failure alerts.

Quick start

  1. Add the two secrets to your Kestra namespace.
  2. Run the flow once with the default inputs and confirm worst_subscriber reads finance-mailing-list, worst_failure_rate reads about 14.81, total_failed reads 22 and over_threshold_count reads 1, and that both the per subscriber and the escalation Slack alerts arrived.
  3. Raise failure_rate_threshold_pct to 20 and re-run to watch the same window pass as healthy while the counters stay identical.
  4. Point your exporter at /api/v1/{tenant}/executions/webhook/{namespace}/sns-fanout-failure-audit/{SNS_METRICS_WEBHOOK_KEY} and enable daily_fanout_audit once the path is trusted.

How to extend

  • Extend the scorer with a filtered rate column and a second threshold so filter policy drift, not just failures, raises an alert.
  • Persist the per subscriber table to a warehouse with io.kestra.plugin.jdbc.postgresql.Queries to chart fanout reliability over weeks.
  • Fan out per topic with io.kestra.plugin.core.flow.ForEachItem over a subflow that audits one topic ARN each.
  • Add an automatic retry publisher step behind an io.kestra.plugin.core.http.Request that replays failed deliveries for topics where replay is safe.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.