A data SLA written in a confluence page is a wish. The same SLA written as assertions the platform runs on every pipeline execution is a contract. The difference is who finds out first when the data is late or short — you, or the analyst building the board pack on top of it.
Most data SLAs I read are prose. “The customer table is refreshed daily by 07:00.” “Transaction records are complete within two hours of close.” These read like commitments. They enforce nothing. Nobody tests them on the day, so the first signal that yesterday’s load ran short by forty thousand rows is a downstream consumer noticing a number looks wrong — usually after it has already flowed into a report, a model, or a regulatory return. By then the question is not “is the data late” but “how far has the bad number travelled.”
The fix is not a better-written SLA. It is an SLA expressed as executable assertions that the platform evaluates every run, emits a pass or fail for, and refuses to let a breach pass silently. Maximum lateness, minimum row count, null tolerance: each of these is a machine-checkable clause. Write them as code and a stale or incomplete dataset is caught by the pipeline that produced it, not by the person who trusted it.
Free · 4 minutes
When two of your systems disagree, do you know which one to believe?
Fourteen questions on ownership, lineage, and quality — the difference between a number on a dashboard and a number you could defend. Banded finding on screen, full sheet by email.
What a data SLA actually promises
Strip the prose away and most data SLAs make three kinds of promise. The first is freshness: the data is no older than some bound. The second is volume: the dataset carries at least as many rows as a healthy run should, and not wildly more. The third is completeness at the column level: the fields that must be populated are populated, within a stated null tolerance. Everything else — schema, referential integrity, distribution — matters too, but freshness and completeness are the promises consumers rely on most and reason about least.
Each promise has a numeric form. Freshness is a maximum lateness in minutes or hours against a timestamp column. Volume is a floor, and usually a ceiling, on row count — sometimes absolute, better expressed relative to a rolling baseline. Null tolerance is a maximum percentage of nulls in a named column. Once a promise has a number, it has a test. The work of turning an SLA into an enforceable contract is mostly the work of pinning down those numbers with the people who depend on the data, and then refusing to let anyone state them only in prose. This is the same discipline as data contracts and governance-by-design pipelines: the contract is only real if the platform can enforce it.
Write the SLA as a spec, then run it
Keep the SLA in a versioned file next to the dataset it governs, not in a wiki. A small YAML spec is enough to hold the three promises for a dataset, and a runner turns that spec into assertions against the warehouse. The point is that the numbers live in source control, change through review, and are read by a machine every run.
# sla/orders.yaml
# Freshness and completeness contract for the orders dataset.
# Numbers are the SLA. Changing them is a reviewed change.
dataset: analytics.orders
timestamp_column: loaded_at
freshness:
max_lateness_minutes: 90 # data must be no older than 90 minutes
volume:
min_rows: 40000 # a healthy daily load; below this we fail
max_rows: 250000 # a run this large is a duplicate-load smell
completeness:
- column: order_id
max_null_pct: 0.0 # primary key, never null
- column: customer_id
max_null_pct: 0.5 # small tolerance for late-binding records
- column: gross_amount
max_null_pct: 0.0
The runner reads the spec, executes one query per clause, and emits a structured pass or fail with the observed value and a timestamp. That last part matters: an assertion result without a timestamp and the actual figure is not audit evidence, it is a green tick you cannot defend later.
#!/usr/bin/env python3
"""Evaluate a data SLA spec against the warehouse and emit pass/fail.
Exit non-zero on any breach so the orchestrator halts the run."""
import sys, json, yaml
from datetime import datetime, timezone
from sqlalchemy import create_engine, text
def scalar(conn, sql):
return conn.execute(text(sql)).scalar()
def evaluate(spec, conn):
ds = spec["dataset"]
ts = spec["timestamp_column"]
results = []
# Freshness: age of the newest row, in minutes.
age = scalar(conn,
f"select extract(epoch from (now() - max({ts}))) / 60 from {ds}")
limit = spec["freshness"]["max_lateness_minutes"]
results.append(("freshness", age is not None and age <= limit,
round(age, 1) if age is not None else None, limit))
# Volume: row count against floor and ceiling.
rows = scalar(conn, f"select count(*) from {ds}")
vol = spec["volume"]
ok = vol["min_rows"] <= rows <= vol["max_rows"]
results.append(("volume", ok, rows, [vol["min_rows"], vol["max_rows"]]))
# Completeness: null percentage per named column.
for c in spec["completeness"]:
col, cap = c["column"], c["max_null_pct"]
pct = scalar(conn,
f"select 100.0 * sum(case when {col} is null then 1 else 0 end) "
f"/ nullif(count(*), 0) from {ds}")
pct = float(pct or 0.0)
results.append((f"null:{col}", pct <= cap, round(pct, 3), cap))
return results
def main(spec_path, dsn):
spec = yaml.safe_load(open(spec_path))
engine = create_engine(dsn)
with engine.connect() as conn:
results = evaluate(spec, conn)
now = datetime.now(timezone.utc).isoformat()
breached = False
for name, passed, observed, threshold in results:
breached = breached or not passed
print(json.dumps({"checked_at": now, "dataset": spec["dataset"],
"check": name, "status": "pass" if passed else "FAIL",
"observed": observed, "threshold": threshold}))
sys.exit(1 if breached else 0)
if __name__ == "__main__":
main(sys.argv[1], sys.argv[2])
You do not have to build this yourself, and for most estates you should not. dbt evaluates source freshness natively — a freshness block with warn_after and error_after, each a count and a period, measured against a loaded_at_field — and dbt tests cover row counts and nulls. Soda expresses the same clauses in SodaCL, with freshness, row_count and missing_percent checks. The runner above exists to show the shape of the thing: a spec in, a timestamped verdict out, a non-zero exit on breach. Whether you reach for dbt, Soda or your own script, the contract is the same.
Wiring it into the run, not bolting it on after
An assertion that runs on a separate nightly schedule, hours after the pipeline, is a monitor. Useful, but it tells you about a breach that has already been consumed. The stronger pattern is to run the assertions as a task inside the pipeline, immediately after the dataset is written and before anything downstream reads it. In an orchestrator — Airflow, Dagster, a dbt build — the SLA check becomes a node with an edge into every consumer. If it fails, the run stops there and the downstream tables are not refreshed from bad input.
This is a deliberate choice between two failure modes. Fail-closed — halt the pipeline on breach — protects consumers absolutely but can leave a stale-but-known-good table serving while you fix the source. Fail-open with a loud alert lets the run continue but flags the breach for a human. For a dataset feeding a regulatory return or a financial control, fail-closed is usually right: a missing update is safer than a wrong one. For a low-stakes internal dashboard, fail-open avoids waking someone at 3am over a rounding-level null. The SLA spec should say which, per dataset, because that too is a promise. The same boundary logic governs streaming, where data contracts at the Kafka boundary decide what a consumer is allowed to receive.
Acting on a breach so it means something
A failing assertion is only worth writing if the failure does something. Three things should happen on breach, and they should be defined before the first check ships. The pipeline should stop or alert according to the fail mode. The breach should be recorded — dataset, check, observed value, threshold, timestamp — as a durable row, not just a log line, so you can show a supervisor how often a dataset met its freshness SLA over a quarter. And an owner should be paged, named in the spec, not “the data team.” A breach with no owner is a breach nobody fixes.
That durable record is the part most teams skip and later wish they had. When a board asks whether the risk data feeding a model was complete and current on a given date, “we think so” is a poor answer. A queryable history of pass and fail results, each stamped with the observed figure, is a strong one. It is the same instinct that makes designing the contract before the code pay off at an API boundary: the specification is the artefact you can point to, and the tests are the proof it held.
The reframe is small and it changes everything about who bears the risk. A prose SLA puts the burden on the consumer to notice something is wrong. A machine-checked SLA puts it on the producer to prove, every run, that the promise held. Move that burden to the right side of the pipeline and stale data stops being something you discover. It becomes something the platform refuses to serve.
Free interactive tool
Website compliance checklist
What your site has to do, based on what it actually does
Answer as much or as little as you like — the list builds as you go. Nothing is stored against your name and no email is required.
Everything that applies
Ordered by what to do first: legal requirements you can close quickly, then larger pieces of work, then what is expected rather than required. Not exhaustive, and not a legal audit.
Dated PDF, yours to keep or circulate.
Can you trust the architecture you have?
Architecture diagrams rarely show the reality of how systems actually operate. An independent review establishes what is really there.