Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 1 of 6 · Concept · 20 min · revision 2

Signals for Data: Freshness, Volume, Schema, Distribution

Learn how to state what "healthy data" means as service level objectives, which signals measure it (freshness, volume, completeness, schema and distribution), and how to send each failed check to the team that owns the dataset. Run all five checks with DuckDB on four weeks of orders that end with one bad day.

Contentsand lesson path

What you will learn

  • Define freshness, volume and completeness SLOs for key datasets and alert on them with clear ownership and routing.

01. Why it matters

A pipeline can finish with a green tick and still deliver bad data. The job ran, but the upstream file was half empty, a column was renamed, or one store's system sent nothing. Job monitoring only tells you that code ran. Data observability asks a different question: is the data that people use complete, current and plausible right now?

Without that, the people who find problems are your consumers: the finance analyst whose report looks odd, or the model whose predictions drift. By then the bad data has been copied into other tables and decisions. Teams that monitor the data itself find most problems before anyone reads the affected tables, and can tell consumers early when something is wrong.

This lesson covers two ideas. First, how to define "good enough" in a way you can measure, using service level objectives. Second, which signals to measure and how to route an alert to someone who can act on it. The lab in the next lesson instruments a full pipeline; here you run the checks on a small table. You need Python 3.10 or newer; the examples were tested with DuckDB 1.5.6.

02. SLIs, SLOs and SLAs for data

Site reliability engineering (SRE) uses three related terms, and they work well for data:

  • A service level indicator (SLI) is a number you measure. For a table, an SLI could be "the time at which yesterday's orders became complete in the orders table" or "the share of orders with no country".
  • A service level objective (SLO) is a target for an SLI over a period: "on 99% of days, yesterday's orders are complete by 07:00 UTC". It has three parts: the indicator, the threshold (07:00) and the target over a window (99% of days in a quarter).
  • A service level agreement (SLA) is a promise to someone else with a consequence if it is broken, such as a refund or an escalation. Not every SLO needs an SLA.

The target matters as much as the threshold. "Always by 07:00" cannot be met, because upstream systems fail sometimes, and a target nobody can meet is soon ignored. A 99% target allows about one late day per quarter. That allowance is the error budget: while it lasts, the team can ship changes; when it is used up, reliability work comes first.

Write SLOs from the consumer's need, not from what the pipeline happens to do today. If the finance team reads the report at 08:00, an SLO at 07:00 leaves an hour to fix problems. Typical data SLOs cover freshness (data arrives in time), volume (about the expected number of rows), and completeness (every expected part is there, such as every store or every hour).

03. Five signals

Each signal catches a different kind of failure, so most important tables check all of them:

  • Freshness: how old is the newest data, and did today's load arrive before its deadline? It catches late or stuck pipelines. Measure it from load metadata, such as a load log or the time a partition was written, rather than by scanning the table.
  • Volume: is the row count in the expected range? It catches empty or partial files and accidental duplicates. Many datasets have weekly patterns, so compare a day with the same weekday in recent weeks, not with the day before.
  • Completeness: is every expected part present? A file per store, a partition per hour, or every key from a reference list. A table can have a normal row count and still miss one store, if the others were busy.
  • Schema: do the columns and types still match the agreed contract? A removed or retyped column usually breaks something downstream. An added column is often harmless but worth knowing about.
  • Distribution: are the values plausible? Examples are the share of nulls in a column, the range of amounts, or the number of distinct countries. It catches bugs where the shape is right and the content is wrong.

Thresholds come from history and from the consumer's needs. Start loose, look at what fires, and tighten, because a check that fires every week for no reason teaches people to ignore it.

04. Run the checks

The first script writes four weeks of orders from five stores to a CSV file and loads it into a DuckDB database file, with a load log that records when each day arrived. The last day, Monday 2026-11-09, has three problems: store s04 sent nothing, a bug left the country empty on about a quarter of the orders, and someone added a column without telling anyone. Create a folder and a virtual environment first.

Terminal
mkdir poc-lab && cd poc-lab
python3 -m venv .venv && .venv/bin/pip install -q duckdb==1.5.6
Python · make_orders.py
"""Write four weeks of orders from five stores to CSV and load them into shop.duckdb.
The last day, 2026-11-09, has problems on purpose."""
import csv
import datetime as dt
import random

import duckdb

rng = random.Random(42)
per_store = {0: 12, 1: 20, 2: 20, 3: 21, 4: 24, 5: 30, 6: 28}   # Mondays are quiet
first = dt.date(2026, 10, 12)                                    # a Monday
with open("orders.csv", "w", newline="") as f:
    out = csv.writer(f)
    out.writerow(["order_id", "store", "order_date", "country", "amount"])
    for d in range(29):
        day = first + dt.timedelta(days=d)
        bad_day = d == 28
        for store in ["s01", "s02", "s03", "s04", "s05"]:
            if bad_day and store == "s04":
                continue                                         # s04 sent no file
            for n in range(per_store[day.weekday()] + rng.randint(-2, 2)):
                country = rng.choice(["GB", "IE"])
                if bad_day and n % 4 == 0:
                    country = ""                                 # a new app bug
                out.writerow([f"{store}-{day:%m%d}-{n:03}", store, day, country,
                              f"{rng.uniform(5, 80):.2f}"])

con = duckdb.connect("shop.duckdb")
con.execute("""
CREATE OR REPLACE TABLE orders AS
SELECT * FROM read_csv('orders.csv', types = {'amount': 'DECIMAL(8, 2)'});
-- One load per day, at 06:20 UTC the next morning.
CREATE OR REPLACE TABLE loads AS
SELECT DISTINCT order_date, order_date + INTERVAL 1 DAY + INTERVAL 380 MINUTE
       AS loaded_at
FROM orders;
ALTER TABLE orders ADD COLUMN voucher_code VARCHAR;   -- added without notice
""")
print(con.sql("SELECT count(*) AS orders, min(order_date) AS first_day, "
              "max(order_date) AS last_day FROM orders"))
Terminal
.venv/bin/python make_orders.py
Expected output
┌────────┬────────────┬────────────┐
│ orders │ first_day  │  last_day  │
│ int64  │    date    │    date    │
├────────┼────────────┼────────────┤
│   3129 │ 2026-10-12 │ 2026-11-09 │
└────────┴────────────┴────────────┘

The checks run as a monitor would at 07:30 UTC the next day. The volume check prints two comparisons for a normal Monday (2026-11-02) and for the bad day: the naive one against the day before, and the band from the median of the same weekday in the four previous weeks, plus or minus 15%. Only the band decides the status.

Python · signals.py
"""Check the orders table as a monitor would at 07:30 UTC on 2026-11-10, print each
signal and save the results to results.json for alert routing."""
import json

import duckdb

DAY = "2026-11-09"                                   # the day that should be loaded
EXPECTED = {"order_id": "VARCHAR", "store": "VARCHAR", "order_date": "DATE",
            "country": "VARCHAR", "amount": "DECIMAL(8,2)"}
con = duckdb.connect("shop.duckdb", read_only=True)
results = []


def q(sql, *params):
    return con.execute(sql, params).fetchone()


def report(signal, status, detail, day=DAY):
    results.append({"dataset": "orders", "day": day, "signal": signal,
                    "status": status})
    print(f"{signal:<13} {detail}  -> {status}")


# Freshness: is the newest day loaded, and did it arrive before 07:00?
day, loaded = q("SELECT order_date, loaded_at FROM loads ORDER BY 1 DESC LIMIT 1")
on_time = str(day) == DAY and str(loaded) <= "2026-11-10 07:00:00"
report("freshness", "OK" if on_time else "FAIL",
       f"{day} loaded {loaded:%H:%M}, deadline 07:00")

# Volume: a naive day-over-day check, and a band from the same weekday.
for d in ("2026-11-02", DAY):                       # a normal Monday, then today
    rows, prev = q("SELECT count(*) FILTER (order_date = ?::DATE), count(*) FILTER"
                   " (order_date = ?::DATE - 1) FROM orders", d, d)
    low, high = q("""SELECT 0.85 * median(n), 1.15 * median(n) FROM (
        SELECT count(*) AS n FROM orders WHERE order_date IN
        (?::DATE - 7, ?::DATE - 14, ?::DATE - 21, ?::DATE - 28) GROUP BY order_date)""",
                  d, d, d, d)
    naive = "OK" if abs(rows - prev) <= 0.1 * prev else "FAIL"
    report("volume", "OK" if low <= rows <= high else "FAIL",
           f"{d}: {rows} rows; day before {prev} ({naive}); band {low:.0f}-{high:.0f}",
           day=d)

# Completeness: did every store send its data?
missing = q("SELECT list(s ORDER BY s) FROM (SELECT DISTINCT store AS s FROM orders"
            " EXCEPT SELECT store FROM orders WHERE order_date = ?::DATE)", DAY)[0]
report("completeness", "FAIL" if missing else "OK", f"stores missing: {missing}")

# Schema: compare the table's columns with the agreed contract.
actual = dict(con.execute("SELECT column_name, data_type FROM information_schema"
                          ".columns WHERE table_name = 'orders'").fetchall())
added = sorted(set(actual) - set(EXPECTED))
changed = sorted(c for c in EXPECTED if actual.get(c) != EXPECTED[c])
report("schema", "FAIL" if changed else "WARN" if added else "OK",
       f"added {added}, missing or retyped {changed}")

# Distribution: share of orders with no country, normally below 2%.
rate = q("SELECT avg((country IS NULL)::INT) FROM orders WHERE order_date = ?", DAY)[0]
report("distribution", "FAIL" if rate > 0.02 else "OK", f"country missing: {rate:.1%}")

with open("results.json", "w") as f:
    json.dump(results, f, indent=1)
Terminal
.venv/bin/python signals.py
Expected output
freshness     2026-11-09 loaded 06:20, deadline 07:00  -> OK
volume        2026-11-02: 54 rows; day before 137 (FAIL); band 50-68  -> OK
volume        2026-11-09: 47 rows; day before 138 (FAIL); band 48-65  -> FAIL
completeness  stores missing: ['s04']  -> FAIL
schema        added ['voucher_code'], missing or retyped []  -> WARN
distribution  country missing: 29.8%  -> FAIL

Freshness is fine: the load arrived at 06:20, before its 07:00 deadline, which shows why freshness alone is not enough. The naive volume check fails on both Mondays, because Sundays are busy and Mondays are quiet; a check like that would fire every week and soon be muted. The weekday band passes the normal Monday and fails the bad one, which is 47 rows against a band of 48 to 65. That failure is close to the edge, so it is the completeness check that makes the cause plain: s04 is missing. The schema check warns about the new column, and the distribution check catches the empty countries, which no row count could see.

05. Owners and alert routing

An alert is only useful if it reaches someone who can act on it, quickly enough. Give every important dataset an owner: the team that can fix it and that answers questions about it. Store that ownership next to the checks, so routing does not depend on who remembers what.

Then decide severity by what the failure does to consumers. Data that is missing or late blocks people, so it can justify a page, an alert that interrupts the on-call engineer at any hour. Suspicious values usually need a person today, not at 3 a.m., so they become a ticket and a message in the team's channel. Warnings are posted for information only. Each alert should say which dataset and check failed, show the evidence (the numbers above), and link to a runbook, a short page that says what to check first.

The script reads the results file that signals.py wrote and an ownership file, and decides where each failure goes.

JSON · owners.json
{
  "orders": {"team": "checkout-data", "pager": "checkout-data-oncall",
             "channel": "#checkout-data-alerts"}
}
Python · route.py
"""Turn failed checks into alerts for the team that owns each dataset."""
import json

owners = json.load(open("owners.json"))
# Severity by signal: data that is missing or late blocks consumers, so page;
# suspicious values need a person today, so open a ticket; a warning is FYI.
PAGE = {"freshness", "completeness"}

for r in json.load(open("results.json")):
    if r["status"] == "OK":
        continue
    owner = owners[r["dataset"]]
    if r["status"] == "WARN":
        where = f"post to {owner['channel']}"
    elif r["signal"] in PAGE:
        where = f"page {owner['pager']}"
    else:
        where = f"ticket to {owner['team']} + {owner['channel']}"
    print(f"{r['dataset']}/{r['signal']} {r['day']} {r['status']}: {where}")
Terminal
.venv/bin/python route.py
Expected output
orders/volume 2026-11-09 FAIL: ticket to checkout-data + #checkout-data-alerts
orders/completeness 2026-11-09 FAIL: page checkout-data-oncall
orders/schema 2026-11-09 WARN: post to #checkout-data-alerts
orders/distribution 2026-11-09 FAIL: ticket to checkout-data + #checkout-data-alerts

Only one failure pages someone: the missing store, which blocks the finance report until it is fixed or explained. In a real set-up, these lines become calls to your paging and chat tools, and an alert that keeps firing is grouped into one incident instead of a new page every five minutes. Review the routing every few months: alerts that nobody acts on should be removed or downgraded.

06. Check your understanding

Practice check · 3 questions

SLOs, signals and routing

Choose the best answer for each situation.

Q1. Which of these is a service level indicator, rather than an objective or an agreement?
Q2. A store's file arrives on time with the usual number of rows, but a currency bug has set half of the amounts to 0. Which check catches it?
Q3. At 03:00 a check fails on a table that nobody reads before 09:00, and the owners can fix it in about 20 minutes. Which response fits best?
Practice only: not graded, not saved, not evidence.

07. Apply it

The skill practice starts here. For the pipeline you will instrument, pick its two most important output tables and write, for each: one freshness SLO and one volume or completeness SLO in the three-part form (indicator, threshold, target over a window); the owner team; which failures page and which open a ticket; and the consumers who must hear about a breach. Keep it in a file next to the pipeline code, so the checks in the next lesson can read it.

08. Review prompt

Without looking back, explain: why a successful job can still produce bad data; the difference between an SLI, an SLO and an SLA; what an error budget is; what each of the five signals catches and one way to measure it; why volume checks compare with the same weekday; and how ownership and severity decide where an alert goes.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check