Quick Overview
This workflow runs hourly or via a webhook to scan a PostgreSQL table for missing required values, duplicate business keys, numeric anomalies, and table health issues, then stores run history and issues in PostgreSQL and sends Slack alerts only when attention is needed.
How it works
- Runs every hour on a schedule or starts on demand when a POST request is sent to the /dq-run webhook.
- Loads the data-quality configuration (table name, key columns, required columns, numeric columns, thresholds, and Slack webhook URL) and validates it before building SQL.
- Queries PostgreSQL to detect missing required values, duplicate business keys (optionally normalized), numeric outliers using a robust z-score, and table health stats (row counts and timestamp freshness).
- Scores completeness, uniqueness, validity, and timeliness, classifies the run as pass/warn/fail/error, and selects the most important issues for reporting.
- Writes the run summary to dq_runs, inserts only newly observed issues into dq_issues, and optionally auto-resolves issues that no longer appear after a full scan.
- Posts a formatted alert to Slack when the run fails/errors, critical issues are found, or new warnings appear; otherwise it stays quiet.
Setup
- Add PostgreSQL credentials for all PostgreSQL nodes and run the manual setup to create the dq_runs, dq_issues, and optional dq_demo_orders tables.
- Update the configuration values (tableName, pkColumn, timestampColumn, requiredColumns, duplicateKeyColumns, numericColumns, scopeHours, and thresholds) to match your PostgreSQL table.
- Provide a Slack incoming webhook URL in slackWebhookUrl and ensure your Slack workspace allows incoming webhooks.
- If using on-demand runs, copy the /dq-run webhook URL from n8n and call it with an HTTP POST from your source system.