Skip to main content

Scalable Ops for data platforms (2/7): define healthy in the data contract

· 10 min read
Shpend Kelmendi
Software Engineer & Architect, Microsoft MVP for Azure

Tom and Lena from part 1 are back. After the Tuesday report that showed Tuesday's numbers on Wednesday, Lena asks a simple question: "What would have told us the load was empty?"

Tom thinks about it. "Nothing. We never wrote down what a good load looks like."

So they write it down, in plain sentences. Yesterday's orders are there by 07:00 UTC. There are at least 5,000 rows. No order ID appears twice. It takes them ten minutes, and it is the first time the team and the business agree on what "healthy" means for the sales report.

This post turns those three sentences into a data contract. It explains what a contract can say about health, which promises are worth making, which ones are not, and how to start without writing contracts for 80 data products.

TL;DR
  • A data contract describes what the consumer of a data product may expect. Health is part of that promise.
  • Group the promise in two parts: the content of the data (rows, keys, values) and the operation (when the data is there, how often it is available).
  • Define three states: healthy, degraded and unhealthy. A failed warning means degraded, a failed error means unhealthy.
  • A good SLO is measurable, relevant to the consumer and reachable. Many first SLOs fail at least one of these.
  • Start with one data product, two or three SLOs taken from real incidents, and warnings before blocking.
  • The contract only defines the promise. Measuring it is the topic of the next parts.
Series: Scalable Ops for data platforms
  • Part 1: the daily ops round does not scale
  • Part 2: define "healthy" in the data contract
  • Part 3a: one health view across the whole platform with Azure Databricks
  • Part 3b: one health view across the whole platform with Microsoft Fabric
  • Part 4a: generate monitoring from the contract with Azure Databricks
  • Part 4b: generate monitoring from the contract with Microsoft Fabric
  • Part 5: operating model: owners, routing and tiers
  • Part 6: AI agents for operations, with a focus on Azure SRE Agent
  • Part 7: lessons learned: replacing the daily ops round

The sales report in this post is a made-up example. Names, addresses and thresholds are placeholders.

What a data contract is​

A data contract is a file that describes a data product from the consumer's point of view. It says who owns the product, what the data looks like, which quality rules hold, and which service levels the owner promises.

I use the Open Data Contract Standard (ODCS). It is an open standard for data contracts in YAML. At the time of writing, the latest version is 3.2.0. The sections that matter for health are:

  • Fundamentals and team: name, version, status, owner and support channel.
  • Schema: the tables and columns, with their types.
  • Quality: rules for the content, such as row count, null values or duplicates.
  • Service levels: promises about operation, such as latency, frequency and availability.

Why the contract is the place for "healthy"​

In part 1 I listed three options for where healthy lives: a data contract, Terraform variables, or documentation per team. Each one works. They differ in what you get and what you pay.

OptionWhat you getWhat it costs
Data contractOne versioned file per data product. The consumer can read it, and a machine can read it too.Every team has to keep its contracts current.
Terraform variablesThe values sit next to the infrastructure that uses them.Consumers rarely read them. The values describe the setup, not the promise.
Documentation per teamEasy to write and easy to read.It drifts, and no tool can use it.

I lean towards the contract for one reason: the next parts generate monitoring from it. That only works if the definition is data, not prose. If you never plan to automate, a well-kept document is a fair choice.

From definition to alert​

The contract is the first step of a longer flow. It helps to see the whole path before looking at the YAML.

  1. Define: the contract lives in the repository, versioned, with an owner. This post.
  2. Measure: the platform produces signals: results of the quality rules, the time of the last load, pipeline status, resource health. Parts 4a and 4b.
  3. Collect: the signals land in one place. Parts 3a and 3b.
  4. Evaluate: a health model compares the signals with the limits from the contract. Parts 3a and 3b.
  5. Notify: the owner is alerted, and everyone sees the same state. Part 5.

Microsoft's documentation makes the same point. In Azure Monitor health models, a signal is a value from a metric or query that is compared with thresholds for each health state, and there is no objective definition of those thresholds: you set them for your workload and business (health model concepts). The Well-Architected guidance recommends defining the thresholds with SLOs (monitoring workload reliability). I did not find a step-by-step path from an SLO or a contract to a health model in the documentation. Part 4 shows one way.

The contract does not measure anything. It says what to measure and which limits count. Without that step, the other four stages draw charts without a reference.

What to promise: the SLOs​

I split the promise in two groups. The first group is about the content of the data. The second is about the operation. The split is a simplification, and the edges are not sharp, but it is enough to start. The first column of the table shows the group.

GroupQuestionODCS elementExample for the sales report
ContentAre the expected rows there?Quality rule rowCount or sqlYesterday's load has more than 0 rows
ContentIs the key usable?nullValues, duplicateValuesNo null and no duplicate order_id
ContentDo the values fit?invalidValuesregion is one of four known values
OperationIs the data there in time?SLA latencyYesterday's orders within 7 hours after the day ends
OperationHow often does it arrive?SLA frequencyOne load per day
OperationCan I read it?SLA availability99.5 percent
OperationHow fast do we notice problems?SLA timeToDetectWithin 30 minutes of the check run at 07:15 UTC

SLOs that look good and are not​

These are patterns I would avoid. This is my opinion from experience, not a rule from the standard.

  • "The data is always correct." Nobody can measure it. Replace it with the concrete rule that failed last time.
  • Absolute promises. "100 percent availability" is unreachable and leaves no room for planned work. "Latency under one minute" for a daily batch is a number no consumer needs and nobody checks. Either way, a promise that is broken on day one teaches everyone to ignore promises.
  • A rule for every column. You get dozens of checks and a lot of noise. This is how alert fatigue starts again, only now it is automated.
  • Thresholds without an incident behind them. If you cannot name the case a rule would have caught, ask why it is there.

A rule of thumb: an SLO should be measurable (a machine can check it), relevant (a consumer would notice the breach) and reachable (the team can keep it with today's setup). If one of the three is missing, rework it before it goes into the contract. For the basics of SLI, SLO and SLA, see my earlier post.

Try the rule of thumb on six candidates. My verdicts are opinions from experience, so disagree where you see it differently.

Would you put this SLO into the contract as it is? Decide for each one. Measurable, relevant, reachable.

  • The data is always correct.
  • Yesterday’s load has more than 0 rows.
  • 100 percent availability.
  • The daily batch arrives within one minute.
  • Yesterday’s orders are there by 07:00 UTC.
  • A null check on every column of every table.

Healthy, degraded, unhealthy​

A list of rules is not enough. When a rule fails, the consumer wants to know how bad it is. I use three states for the sales report:

StateWhat it meansExample
HealthyAll rules pass and the data is on time.Data at 06:50 UTC, 12,000 rows, no duplicate order_id.
DegradedThe data is usable, but with care. A warning rule fails, or the data is late.Only 3,000 rows, which can be a quiet day or a partial load. Or the data arrives at 08:00 UTC.
UnhealthyDo not trust the report. An error rule fails, or the data is very late.0 rows, a duplicate order_id, or no data at 10:00 UTC.

ODCS has no health states. The mapping is my convention: severity: warning means degraded and severity: error means unhealthy. For late data, the latency promise is the limit for healthy. A custom property holds the limit for unhealthy, here 9 hours. All numbers are placeholders.

The line between degraded and unhealthy matters because of how Azure Monitor health models count. A health objective is a target share of healthy time. Unhealthy counts as downtime, degraded does not (health model concepts). Moving one rule from warning to error changes the number you report.

Try it below. Move the arrival time of the load and change its content to see which state the contract gives.

Move the slider and change the content of the load. The state follows from the contract.

Sales report, day D. All values are placeholders from the example contract.

Load arrives Check run at 07:15 UTC

Healthy
  • All rules pass and the data is on time.

The example contract​

Here are the parts of the sales report contract that define health, shortened.

apiVersion: v3.2.0
kind: DataContract
name: sales-report
version: 1.0.0
status: draft
team:
name: sales-data
members:
- username: sales-data-owners@example.com
role: owner

The first block gives the contract an identity and an owner. Someone has to be named, or nobody feels responsible for the numbers. In this example, the owner is also the group that is notified when a rule fails. Routing and tiers follow in part 5.

schema:
- name: sales_daily
quality:
- id: sales_daily_not_empty
type: sql
query: SELECT COUNT(*) FROM ${table} WHERE order_date = current_date() - 1
mustBeGreaterThan: 0
dimension: completeness
severity: error
scheduler: cron
schedule: 15 7 * * *
- id: sales_daily_volume_plausible
type: sql
query: SELECT COUNT(*) FROM ${table} WHERE order_date = current_date() - 1
mustBeGreaterOrEqualTo: 5000
dimension: completeness
severity: warning
properties:
- name: order_id
quality:
- id: order_id_no_nulls
metric: nullValues
mustBe: 0
- id: order_id_unique
metric: duplicateValues
mustBe: 0

The quality block holds the rules for the content. The first rule would have caught the empty file from part 1. It is an error, because an empty load is never acceptable. The second rule is a warning, because a low count can be a quiet day. ${table} is the placeholder the standard uses for the table name. The check runs at 07:15 UTC, 15 minutes after the 07:00 deadline from the service levels below. A check before the deadline would flag every load that is merely not due yet.

slaProperties:
- id: sales_daily_latency
property: latency
value: 7
unit: h
element: sales_daily.order_date
- id: sales_daily_time_to_detect
property: timeToDetect
value: 30
unit: m
customProperties:
- property: unhealthyLatencyHours
value: 9

The service levels hold the promises about operation. I use latency for timeliness, because the ODCS documentation prefers it over freshness. The custom property at the end marks when late data turns unhealthy.

Each line answers a question from the Tuesday incident. Click through the lines to see which one, and what happens when it fails:

Click a highlighted line to see which question it answers.

team:
members:
role: owner
schema:
- name: sales_daily
quality:
- id: sales_daily_not_empty
severity: error
- id: sales_daily_volume_plausible
severity: warning
properties:
- name: order_id
quality:
mustBe: 0
mustBe: 0
slaProperties:
value: 7
unit: h
value: 30
unit: m
customProperties:
value: 9

Rule: not empty

Did an empty file arrive again?

Yesterday’s load has more than 0 rows. This is the rule that would have caught the empty file from part 1.

If it fails
Unhealthy, because severity is error.
In the flow
Defined here, measured in part 4, evaluated in part 3.

How to start​

Do not start with the platform. Start with one data product.

  1. Pick one data product that has caused repeated trouble and that people read every day.
  2. Ask the consumer what bothered them last time. Not what they might want in theory.
  3. Take two or three SLOs from real incidents. An empty load, a late load, a broken key.
  4. Write the contract and review it with the owner and the consumer. Check each SLO against measurable, relevant and reachable.
  5. Start with warnings. Block only for the few rules where a breach is never acceptable, such as the empty load.
  6. Review after a few weeks with real numbers, and adjust the thresholds. Remove rules nobody has needed.

If you took the baseline from part 1, you can already see whether detection gets faster.

Which layer gets a contract?​

I do not decide this by layer. I decide it by consumer. A contract is a promise to someone who reads the data, so the first question is: who reads this table, and who depends on it?

ConsumersContract?Example
None, only your own pipeline reads itNo consumer contract. Quality checks on the step into the next layer are enough.The raw file arrives, the schema matches, there is more than 0 rows.
One team or report depends on itYes, with an owner and a few SLOs.sales_daily, read by the sales report.
Several consumersYes, and ask each of them.The same table feeds the report and a forecast model.

Most of the time, this points to gold. Some silver tables have consumers too, for example data science, and then they need a contract. ODCS has no concept of layers, so this is my view from experience, not a rule of the standard.

Other authors take a different route. Microsoft's medallion decision guide suggests a contract per layer, strict at gold and more forgiving at bronze. That works too. I prefer the consumer as the test, because it keeps the number of contracts small. A layer without a reader does not need a promise.

With several consumers, the contract is the one place where their needs meet. If one wants the data by 07:00 and another does not care, you see it before the first incident, not after.

The checks on bronze still matter. The empty file from part 1 arrives in bronze, so a check there finds it first. But that check is internal. The promise stays with the table the consumer reads. If bronze is unhealthy, the tables above it are too. That dependency belongs to the health model in parts 3 and 4, not to the contract.

Pitfalls​

  • Realistic SLOs take practice. The first numbers will be wrong. Plan the review, or the contract goes stale.
  • A contract does not monitor anything. It states the promise. Until the next parts, nothing checks it.
  • Someone has to own the file. A contract without a maintaining owner is documentation again.
  • More rules are not better. Every rule is something a person has to understand when it fails.

My take​

I chose ODCS for three reasons. It is a standard, so I don't invent a format that only my team understands. People and machines can both read it. And it can be extended: the standard has custom properties for what it does not cover. Because it is plain YAML, Terraform can read it with yamldecode. That is the basis for generating monitoring from the contract in part 4.

On the content, my advice is to promise less and to prioritize. Start with the few SLOs that matter most, and add more when an incident shows a gap. A contract with too many rules brings back the alert fatigue from the round, only automated.

A contract needs an owner. Someone has to create it, maintain it and extend it, or it goes stale. That is why the contract defines an owner group, not a single person. The same group is notified when a rule fails.

How many SLOs do you start with for a data product? I would like to hear what worked for you and what only produced noise.

Lessons learned​

  • Write the promise down first. Without a definition of healthy, monitoring only produces charts.
  • Separate content from operation. It keeps the contract readable for people who are not platform engineers.
  • Take SLOs from incidents. A threshold with a story behind it survives its first review.
  • One data product is enough to start. It gives you a template, real numbers and a first argument for the next one.

In part 3, I look at where the signals come together: one health view across the whole platform, once with Azure Databricks and once with Microsoft Fabric.

References​