Data Observability with Monte Carlo Patterns Guide

In modern data platforms, traditional monitoring tools only track whether infrastructure is up or down: is the warehouse online, did the Airflow DAG finish, is the disk full. They say nothing about whether the data itself is correct. A pipeline can run "successfully" and still load half the usual rows, drop a column, or fill a field with nulls, and nobody notices until a dashboard shows the wrong revenue or a machine learning model starts making bad predictions.

Data observability closes that gap. It applies the ideas of application performance monitoring (APM) to data: instead of watching servers, it continuously watches the health of tables and pipelines, learns what "normal" looks like, and alerts when the data drifts away from it. This guide explains the five pillars of data observability popularised by Monte Carlo, shows how to measure each one, and builds a Python anomaly detector that uses a Monte Carlo simulation to set alert thresholds.

What Is Data Observability?

Data observability is the ability to understand the health and state of the data in your systems at any moment. A data observability system collects metadata and statistics about your tables (row counts, update times, schemas, null rates, value distributions, lineage), compares them with their history, and raises an alert when something unexpected happens.

It is often confused with two related practices. They work together, but they answer different questions:

PracticeQuestion it answersHow it worksWeakness on its own
Infrastructure monitoringIs the system running?Checks CPU, memory, job status, uptimeA job can succeed and still load bad data
Data quality testingDoes the data meet rules I wrote?Assertions such as "id is unique" or "amount is not null"Only catches problems someone predicted in advance
Data observabilityIs the data behaving normally?Learns baselines from history and detects deviationsNeeds history, and thresholds must be tuned

The key difference is that tests catch known unknowns (problems you thought of), while observability also catches unknown unknowns (problems nobody thought to test for, such as a partner API silently sending 80% fewer records).

Two Meanings of "Monte Carlo"

The name "Monte Carlo" appears in data engineering in two different ways, and this guide uses both:

  • Monte Carlo, the data observability company, popularised the idea of measuring data health across five pillars: freshness, distribution, volume, schema and lineage. The pillars below follow that model.
  • Monte Carlo simulation, the statistical technique, estimates a range of likely outcomes by drawing thousands of random samples. In the script later in this guide, it is used to work out the range a normal day's row count should fall in, and anything outside that range raises an alert.

The Five Pillars of Data Observability

Each pillar looks at a different way data can go wrong. Monitoring all five gives a complete picture of a table's health.

PillarQuestionTypical metricExample failure it catches
FreshnessIs the data up to date?Hours since the last loadA nightly job silently stopped running
VolumeIs the amount of data normal?Row count per load or per dayAn extract loaded only half the rows
DistributionDo the values look normal?Null rate, min, max, mean, distinct countA field became 15% null after an API change
SchemaHas the structure changed?Column names and data typesA column was renamed and downstream joins broke
LineageWhat depends on this table?Upstream and downstream dependenciesFinding every dashboard affected by a bad table

Freshness

Freshness measures how recently a table was updated compared with how often it is expected to update. If an orders table normally loads every hour and the last load was nine hours ago, something upstream has stalled, even if no job reported an error.

Freshness checks need an SLA (service level agreement) for each important table, for example "the orders table must never be more than 6 hours old". The check then compares the latest load timestamp with the current time.

Volume

Volume tracks how much data arrives: rows per load, rows per day, or table size in bytes. A sudden drop usually means an incomplete extract, a failed partition, or an upstream filter that changed. A sudden spike can mean duplicated loads or a backfill that ran twice.

Volume is the easiest pillar to measure and one of the most valuable, because truncated loads are one of the most common silent failures in ETL pipelines.

Distribution

Distribution checks look inside the data: the share of nulls in a column, the minimum and maximum values, the average, the number of distinct values, and the frequency of each category. These catch problems where the row count looks fine but the content is wrong, for example:

  • A price column suddenly containing zeros for every row.
  • A country column where 40% of values change to "Unknown".
  • A percentage field arriving as 0 to 100 instead of 0 to 1.

Schema

Schema monitoring records the columns and data types of each table and alerts when they change. Added, removed, renamed or retyped columns are a frequent cause of broken pipelines, because downstream SQL and models assume a fixed structure. A schema change is not always a mistake, but it should never be a surprise.

Lineage

Lineage maps how data flows: which source tables feed each model, and which dashboards and reports read from it. Lineage does not detect problems by itself. Instead, it answers the two questions you need during an incident:

  • Root cause: which upstream table or job introduced the problem?
  • Impact: which downstream tables, dashboards and teams are affected?

How a Data Observability Pipeline Works

Whether you buy a platform or build your own, the workflow follows the same steps:

  1. Collect metadata. Read query logs, information schema tables and load timestamps from the warehouse (Snowflake, BigQuery, Databricks and others expose these).
  2. Compute metrics. For each monitored table, calculate freshness, row counts, null rates and distribution statistics on a schedule.
  3. Learn a baseline. Store the metrics over time and work out what a normal range looks like for each one.
  4. Detect anomalies. Compare each new measurement with its baseline using z-scores, simulated ranges or forecasting models.
  5. Alert the owner. Send the alert to the team that owns the table, with enough context to act on it.
  6. Triage with lineage. Use lineage to find the root cause upstream and warn the owners of affected dashboards downstream.

Measuring the Pillars with SQL

Most metrics can be collected with simple queries. The examples below use BigQuery SQL; other warehouses have equivalent functions.

SQL
Daily row counts for the volume baseline (BigQuery)
SELECT
  DATE(loaded_at) AS load_date,
  COUNT(*) AS row_count
FROM analytics.orders
WHERE loaded_at >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
GROUP BY load_date
ORDER BY load_date;
SQL
Freshness: hours since the last load (BigQuery)
SELECT
  MAX(loaded_at) AS last_loaded_at,
  TIMESTAMP_DIFF(CURRENT_TIMESTAMP(), MAX(loaded_at), HOUR) AS hours_since_load
FROM analytics.orders;
SQL
Distribution: null rate of a column (BigQuery)
SELECT
  COUNTIF(customer_email IS NULL) / COUNT(*) AS null_rate
FROM analytics.customers;
SQL
Schema: current columns and types, to compare with yesterday's snapshot (BigQuery)
SELECT column_name, data_type
FROM analytics.INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'orders'
ORDER BY ordinal_position;

Python Automated Data Quality Anomaly Detection Script

The script below puts the ideas together. It builds 30 days of mock metrics for a table, simulates a bad load on the last day, and then runs three checks: freshness, volume and distribution.

Python
Python script that checks freshness, volume and null rate, using a z-score and a Monte Carlo simulation to set the expected range
import numpy as np
import pandas as pd


def build_metrics(days=30, seed=42):
    """Mock 30 days of table metrics, with a bad load on the last day."""
    rng = np.random.default_rng(seed)
    dates = pd.date_range("2026-10-01", periods=days, freq="D")
    row_counts = rng.normal(50_000, 2_500, days)
    null_rates = rng.normal(0.01, 0.002, days)
    row_counts[-1] = 12_000   # simulated truncated load
    null_rates[-1] = 0.15     # simulated upstream break
    return pd.DataFrame({"date": dates, "row_count": row_counts, "null_rate": null_rates})


def zscore_against_history(series, window=14):
    """Z-score of the latest value against the previous `window` days only."""
    history = series.iloc[-(window + 1):-1]
    return (series.iloc[-1] - history.mean()) / history.std(ddof=1)


def monte_carlo_bounds(series, window=14, simulations=10_000, tail=0.001, seed=7):
    """Draw many plausible 'normal' days from the recent history and use the tails as alert bounds."""
    rng = np.random.default_rng(seed)
    history = series.iloc[-(window + 1):-1]
    simulated = rng.normal(history.mean(), history.std(ddof=1), simulations)
    return np.quantile(simulated, [tail, 1 - tail])


def check_freshness(last_loaded_at, now, max_delay_hours=6):
    delay = (now - last_loaded_at).total_seconds() / 3600
    return delay, delay <= max_delay_hours


def check_table(df, last_loaded_at, now, z_threshold=3.0, max_null_rate=0.05):
    latest = df.iloc[-1]
    alerts = []

    delay, fresh = check_freshness(last_loaded_at, now)
    if not fresh:
        alerts.append(f"Freshness: last load was {delay:.1f} hours ago.")

    z = zscore_against_history(df["row_count"])
    low, high = monte_carlo_bounds(df["row_count"])
    print(f"Table health for {latest['date']:%Y-%m-%d}")
    print(f"  Row count: {latest['row_count']:,.0f} (z-score {z:.1f}, expected {low:,.0f} to {high:,.0f})")
    print(f"  Null rate: {latest['null_rate']:.1%}")
    if abs(z) > z_threshold or not low <= latest["row_count"] <= high:
        alerts.append(f"Volume: {latest['row_count']:,.0f} rows is outside the expected range.")

    if latest["null_rate"] > max_null_rate:
        alerts.append(f"Distribution: null rate {latest['null_rate']:.1%} exceeds {max_null_rate:.0%}.")

    if alerts:
        print("[ALERT] Anomalies detected:")
        for alert in alerts:
            print(f"  - {alert}")
    else:
        print("Table health check passed.")
    return alerts


if __name__ == "__main__":
    metrics = build_metrics()
    check_table(
        metrics,
        last_loaded_at=pd.Timestamp("2026-10-30 02:15"),
        now=pd.Timestamp("2026-10-30 11:00"),
    )

Output

Running the script with Python, NumPy and pandas prints:

TEXT
Table health for 2026-10-30
  Row count: 12,000 (z-score -23.4, expected 45,011 to 55,024)
  Null rate: 15.0%
[ALERT] Anomalies detected:
  - Freshness: last load was 8.8 hours ago.
  - Volume: 12,000 rows is outside the expected range.
  - Distribution: null rate 15.0% exceeds 5%.

How the Script Works

  • build_metrics() creates 30 days of row counts around 50,000 and null rates around 1%, then breaks the last day: only 12,000 rows and a 15% null rate. In a real system these numbers would come from the SQL queries above.
  • zscore_against_history() compares the latest value with the previous 14 days only. Excluding the latest value matters: if the bad day were included in its own baseline, it would pull the mean down and widen the standard deviation, making the anomaly look smaller than it is.
  • The z-score is the number of standard deviations the latest value sits from the recent average. A value beyond 3 (or below -3) is very unlikely to be normal variation. Here the row count is 23.4 standard deviations below normal.
  • monte_carlo_bounds() is the Monte Carlo step. It simulates 10,000 plausible normal days from the mean and spread of the recent history, then takes the 0.1% and 99.9% quantiles as the expected range: 45,011 to 55,024 rows. Anything outside that range is flagged.
  • check_freshness() compares the last load time with the current time against a 6-hour SLA. The last load was 8.8 hours ago, so freshness fails as well.
  • check_table() runs all checks and prints every alert together, so the on-call engineer sees the full picture of the incident at once.

The simulation in this example assumes daily counts follow a normal distribution, so its bounds closely match a plain mean plus or minus a few standard deviations. The approach becomes more useful when you replace rng.normal(...) with a model of your real data, for example resampling past values, adding a weekly pattern, or simulating from a forecast. The rest of the check stays the same.

A Typical Incident, Step by Step

To see how the pillars work together, imagine the alert from the script fires on the orders table at 11:00:

  1. Freshness and volume alerts arrive together. The table is 8.8 hours old and the last load contained only 12,000 rows instead of about 50,000.
  2. Lineage shows the upstream source. The orders table is built from a raw extract of the payment provider's API.
  3. The extract job log shows the cause. The provider changed its pagination, and the job stopped after the first few pages without an error.
  4. Lineage shows the impact. Three dashboards and a revenue forecast model read from the orders table, so their owners are warned not to trust today's figures.
  5. The fix and backfill run. After the extract is fixed and the missing data reloaded, the metrics return to their normal range and the alerts clear.

Without observability, the first sign of this problem would probably have been a finance team member asking why yesterday's revenue dropped by 75%.

Data Observability Best Practices

  • Start with critical tables. Monitor the tables that feed revenue reporting, customer-facing features and machine learning models first, rather than every table at once.
  • Automate metadata collection. Read schemas, load times and query logs directly from the warehouse on a schedule instead of relying on people to report problems.
  • Exclude the current value from its baseline. Compare each new measurement only with history, as the script does, so a large anomaly cannot hide itself.
  • Use dynamic thresholds. Fixed limits such as "alert below 40,000 rows" break during seasonal changes and growth. Baselines learned from recent history, simulations or forecasts adapt automatically.
  • Account for seasonality. Many tables have weekly patterns, for example fewer orders at weekends. Compare Mondays with previous Mondays, or model the weekly cycle, to avoid false alarms.
  • Give every table an owner. Each alert should go to a team that can fix the problem, not to a shared channel nobody reads.
  • Prioritise root cause analysis. Use column and table lineage to trace a broken dashboard back to the exact upstream job that failed.
  • Fight alert fatigue. Group related alerts into one incident and tune thresholds that fire too often. An alert that is regularly ignored is worse than no alert.
  • Combine observability with tests. Keep explicit tests for business rules you know, such as unique keys and valid ranges, and use observability for everything you did not anticipate.

Common Mistakes

  • Including today's value in today's baseline: this hides large anomalies, because the bad value shifts the average and widens the standard deviation.
  • Using a baseline window that is too short: with only a few days of history, normal variation looks like an anomaly. Two to four weeks is a common starting point for daily data.
  • Ignoring weekends and holidays: a weekly drop that happens every Saturday is not an incident. Model the pattern instead of alerting on it.
  • Monitoring only row counts: the count can be perfect while a key column is full of nulls or wrong values. Add distribution checks for important columns.
  • Alerting without context: an alert that says only "anomaly detected" forces the engineer to start from scratch. Include the table, metric, expected range, actual value and owner.

Summary

Data observability treats data reliability like application reliability. Instead of waiting for users to report broken dashboards, it continuously measures the five pillars popularised by Monte Carlo (freshness, volume, distribution, schema and lineage), learns what normal looks like, and alerts when a table behaves unexpectedly. In this guide you saw how to measure each pillar with SQL, how to detect anomalies with z-scores and a Monte Carlo simulation in Python, and how lineage turns an alert into a fast root cause analysis. Start with a handful of critical tables, use dynamic thresholds and clear ownership, and expand coverage as your data platform grows.