keepcalculator

06 Numbers and Powers

Data Pipeline Observability: Stop Failures Early

Card No. 06·40250 · Updated · Standard formula, shown below

This guide shows you how to build observability into your data pipelines so you catch anomalies, schema changes, and data quality issues before they propagate to downstream systems. You’ll learn to implement proactive checks, monitoring, and alerting that give you early warning—not just post-mortem logs. By the end, you’ll have a practical framework for reducing silent data corruption and costly firefighting.

What You’ll Need

  • Access to your pipeline orchestration tool (Airflow, Dagster, Prefect, or similar)
  • Access to your data warehouse or data lake (Snowflake, BigQuery, Redshift, S3, etc.)
  • A monitoring/alerting platform (Datadog, Prometheus, Grafana, or even Slack webhooks)
  • Basic familiarity with SQL and Python (or your pipeline’s scripting language)
  • Ability to add code to your pipeline’s transformation steps

Step-by-Step

  1. Define your data quality SLAs. For each critical table or dataset, write down the non-negotiables: row count ranges, freshness (max time since last update), schema (columns and types), and business rules (e.g., no negative sales). Start with the few that matter most—don’t boil the ocean.
  2. Instrument your pipeline with structured logs. Every task should emit JSON logs with at least: timestamp, job name, task name, row counts read/written, duration, and any error codes. This gives you a searchable history for troubleshooting.
  3. Add a schema validation step early. After extraction and before transformation, compare the incoming data’s schema to the expected schema. If a column is missing or a type changed, fail fast. Use a library like Great Expectations or a simple SQL query against information_schema.
  4. Implement row count and freshness checks. In your orchestration tool, add a task that checks the row count of the target table against a threshold (e.g., not zero, not 10x the historical average). Also check the max timestamp of the data—if it’s older than your SLA, fail the pipeline.
  5. Set up anomaly detection on key metrics. For numeric columns (revenue, user count, etc.), compute a rolling average and standard deviation. Alert if the current value deviates by more than, say, 3 standard deviations. You can do this in SQL or in your monitoring tool.
  6. Create a data quality test suite. Write a set of SQL queries that assert business rules: no null primary keys, no negative quantities, referential integrity with parent tables. Run these as a separate step after each load. If any fail, halt downstream tasks.
  7. Add a circuit breaker to downstream tasks. In your orchestration DAG, make downstream tasks depend on the success of the quality checks. If a check fails, don’t run the downstream transformation—instead, alert the team and keep the raw data intact for investigation.
  8. Set up real-time alerting. Configure your monitoring platform to send alerts to a dedicated Slack channel or PagerDuty when a check fails. Include the failing check name, the dataset, and a link to the logs. Set different severities: warning for anomalies, critical for SLA breaches.
  9. Build a dashboard for pipeline health. Create a dashboard showing the status of each pipeline, the last successful run, current data freshness, and the number of active alerts. Make it visible to the whole team—this encourages ownership.
  10. Document and iterate. When an alert fires, write a short post-mortem in your runbook: what happened, how you detected it, and what check would have caught it earlier. Add that check to your suite. Review your SLAs quarterly.

Common Mistakes

  • Monitoring only infrastructure (CPU, memory) and ignoring data content. A pipeline can run perfectly but produce garbage.
  • Setting thresholds too tight or too loose. Start with generous bounds and tighten as you learn your data’s natural variation.
  • Checking only after the load completes. You need checks at multiple stages—after extract, after transform, and after load.
  • Alerting on every tiny anomaly, causing alert fatigue. Use severity levels and aggregate related alerts.
  • Not testing the alerting itself. If your alerting fails silently, you’re blind. Periodically send a test alert.

Tips

  • Start with the top 3 pipelines that feed your most critical reports or models. Expand gradually.
  • Use a data quality framework like Great Expectations or Soda Core to avoid reinventing the wheel.
  • Make your checks idempotent—they should produce the same result regardless of when they run.
  • Store check results in a dedicated table so you can track trends over time and prove improvements.
  • Involve data analysts early—they know the business rules better than anyone.

Troubleshooting

  • Alerts aren’t firing. Check that your monitoring tool is receiving the pipeline’s logs. Verify the alert conditions are actually met (run the query manually). Test the webhook/notification endpoint.
  • False positives. Your thresholds are too tight or your data has seasonal patterns. Add a time-of-day or day-of-week component to your anomaly detection, or widen the bounds.
  • Checks slow down the pipeline. Run checks in parallel with transformations where possible, or sample large tables instead of scanning the whole thing. Use approximate counts (e.g., COUNT(*) APPROXIMATE in BigQuery).
  • Downstream systems still get bad data. You may have a gap in coverage—e.g., you check row counts but not column-level quality. Add checks for null rates, unique counts, and value ranges.
  • Logs are too verbose to be useful. Implement a log level (DEBUG, INFO, WARN, ERROR) and only send WARN and above to your monitoring platform.

Frequently Asked Questions

What’s the difference between monitoring and observability?

Monitoring tells you something is wrong (a metric is out of bounds). Observability lets you ask why—it’s achieved through logs, traces, and rich context, so you can diagnose the root cause without guessing.

How often should I run quality checks?

For batch pipelines, run them after every load. For streaming pipelines, run them on micro-batches or every few minutes. The key is to catch issues before the data is consumed.

What if my data is legitimately volatile?

Use relative thresholds (e.g., percentage change from the previous day) instead of absolute values. Also consider using a longer rolling window for the baseline.

Can I do this without a dedicated observability tool?

Yes. You can use your orchestration tool’s built-in sensors, plus a simple script that sends results to a Slack webhook. It’s less polished but works for small teams.

How do I handle schema changes that are intentional?

Have a formal change process: update the expected schema in your validation config, then deploy the change alongside the pipeline update. The check should fail if the schema doesn’t match the config, so you’re forced to update it deliberately.

What’s the best way to alert on data freshness?

Use the pipeline’s scheduled run time as the reference. If the data’s max timestamp is older than the expected interval (e.g., daily data should have yesterday’s date), raise an alert. This catches both late data and empty loads.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →