Trigger icon
SlackIncomingWebhook icon
Query icon

Notify Slack on new Vertica rows

Trigger Kestra on new Vertica rows, post a batched Slack alert with retries, then mark only the alerted order ids as processed.

Categories
Data

Event-driven Kestra flow that watches a Vertica analytics table for unprocessed rows, posts a single batched Slack alert per poll window, and then marks only the alerted order_ids as processed. Built for honest at-least-once delivery on a columnar warehouse: a row is never flipped to processed = true before its Slack notification has actually succeeded, so transient webhook failures cannot silently drop orders. Replaces brittle in-trigger afterSQL updates with a safer flow-side update scoped to the exact ids that were alerted.

How it works

  1. The poll_new_orders trigger (io.kestra.plugin.jdbc.vertica.Trigger) runs every PT5M, selecting up to 500 rows from staging.orders where processed = false, ordered by order_id. The LIMIT 500 keeps batches bounded so a backlog cannot blow up memory.
  2. When rows are returned, the execution exposes them as {{ trigger.rows }} and the count as {{ trigger.size }}. The order_ids variable joins the ids into a comma-separated list for the downstream UPDATE.
  3. notify_batch (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) posts one batched message containing the count, the full id list, and the first order's detail. A constant retry (5 attempts, PT10S interval) absorbs Slack 429 and 5xx responses.
  4. mark_processed (io.kestra.plugin.jdbc.vertica.Query with fetchType: NONE) runs only after the alert succeeds, executing UPDATE staging.orders SET processed = true WHERE order_id IN (...) scoped to the alerted ids.
  5. The flow-level errors block posts a second Slack message naming the execution id and the affected ids if anything fails, so re-alerted batches are never invisible.

What you get

  • Bounded, batched alerts that respect Slack's rate limits instead of one webhook per row.
  • Honest at-least-once semantics: rows alerted but not yet marked simply re-fire next poll.
  • A scoped UPDATE that touches only the alerted ids, immune to inserts arriving between SELECT and UPDATE.
  • Built-in retries on both the Slack post and the Vertica update, plus a visible failure path.

Who it's for

  • Data and analytics engineers wiring Vertica into operational alerting.
  • Platform teams that need to notify Slack on new warehouse rows without standing up a separate change-data-capture stack.
  • On-call teams that want explicit, named alerts on delivery failures rather than silent drops.

Why orchestrate this with Kestra

Vertica's own scheduler can run SQL, but it cannot wait on a Slack webhook, decide whether to mark rows based on that webhook's HTTP response, retry only the failed step, or surface failures with the affected ids. Kestra's event trigger turns a SELECT into a real workflow: declarative YAML, per-task retry, timeout, a flow-level errors block, full execution lineage in the UI, and concurrency.limit style serialization so overlapping polls cannot double-process a window. The trigger fires on data, not on a clock guess, and the marking step is conditional on alert success, something an in-database job simply cannot express.

Prerequisites

  • A reachable Vertica cluster and a staging.orders table with order_id, customer_name, product, total, and a boolean processed column.
  • A Slack incoming webhook URL for the target channel.
  • The vertica_url variable updated to your JDBC URL (default jdbc:vertica://vertica-host:5433/analytics).

Secrets

  • VERTICA_USERNAME: Vertica database user used for both the trigger poll and the flow-side update.
  • VERTICA_PASSWORD: password for that Vertica user.
  • SLACK_WEBHOOK: Slack incoming webhook URL used by notify_batch and the alert_failure error handler.

Quick start

  1. Add VERTICA_USERNAME, VERTICA_PASSWORD, and SLACK_WEBHOOK to your Kestra namespace secrets.
  2. Update the vertica_url variable and the trigger SQL to match your table, schema, and unprocessed-flag column.
  3. Adjust the trigger interval (PT5M is a good default for a warehouse; sub-minute polling is not recommended for columnar storage).
  4. Insert a row with processed = false in staging.orders to see an execution start, a Slack message land, and the row flip to processed = true.

How to extend

  • Swap the batched Slack post for a Microsoft Teams, PagerDuty, or Opsgenie task to route alerts to the right on-call surface.
  • Add a fan-out subflow (io.kestra.plugin.core.flow.Loop) over {{ trigger.rows }} to enrich each order before notifying.
  • Persist the alerted batch to object storage (S3, GCS, Azure Blob) for audit before marking processed.
  • Replace the processed boolean with a watermark column (e.g. alerted_at TIMESTAMP) and adapt the SELECT and UPDATE accordingly.
  • For high-volume sources, move off polling and adopt change data capture from the upstream OLTP system into Vertica, then trigger on the CDC stream.

Links

Orchestrate with Kestra
Orchestrate Slack with Kestra
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.