Ir para o conteúdo

Lição 12 · Data Quality

Quality Monitoring and Root Cause Analysis

Monitor data quality over time, build useful scorecards, manage data issues as tickets, and find root causes with the five whys so problems stop returning.

Measuring quality once tells you the current state. Monitoring tells you whether things are getting better or worse and warns you when something breaks. Cleaning data without fixing the cause is like mopping a floor under a leaking pipe.

What to monitor

Besides your quality rules, watch basic health signals of each important dataset:

Signal Question
Freshness Did new data arrive on time?
Volume Is the row count within the expected range?
Schema Did columns appear, vanish or change type?
Distribution Did values shift sharply, such as 40% suddenly "unknown"?
Rule results Which rules failed, and how often?

Many tools call this family of checks data observability. The ideas work with plain SQL and a scheduler too.

Detecting unusual volume

A fixed threshold works for stable data. For data with normal variation, compare today with recent history. The example uses the median of the earlier days, which resists the effect of a single extreme day.

Python Flag unusual daily row counts

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The 30% limit is an example. Real data may need weekday-aware comparisons, because weekends or month-ends often look different. Tune thresholds until alerts are mostly worth acting on.

Scorecards

A scorecard shows quality by dataset and rule, with trends and owners. Keep it readable:

Rule Severity Oct Nov Target Owner
Delivery address present blocker 98.1% 99.7% 99.5% Orders steward
Plan code valid high 99.9% 99.9% 99.9% Customer steward
Email format valid medium 96.4% 95.8% 98.0% Marketing steward

These are made-up numbers. Show the trend and the failed row count too, because 1% of ten rows and 1% of ten million rows are very different problems.

Manage issues like work

Each quality problem that needs action becomes an issue with an owner, a severity, a due date and a status. A simple flow:

flowchart LR
  A["Detected"] --> B["Triage"]
  B --> C["Contain"]
  C --> D["Find root cause"]
  D --> E["Fix and prevent"]
  E --> F["Verify and close"]

Containment limits damage quickly; the root cause fix stops it from coming back.

Containment might mean pausing a pipeline, marking a report as unreliable or telling consumers. Tell people early. Silent errors damage trust far more than announced ones.

Root cause analysis: the five whys

Ask "why?" repeatedly until you reach a cause you can change. Example:

  1. Why were invoices sent to the wrong address? The address was outdated.
  2. Why was it outdated? The customer updated it in the web account, not in billing.
  3. Why did billing not receive the update? No integration sends address changes.
  4. Why not? The original project assumed one system.
  5. Why was that never revisited? Nobody owns the address across systems.

The fix is not "clean the addresses". It is naming a system of record, creating the flow and giving someone ownership. Five is not a magic number; stop when you reach something actionable, and consider that there may be several causes.

Common root cause families include missing validation at entry, unclear definitions, manual copying, uncommunicated schema changes, different time zones or units, and incentives that reward speed over correctness.

Stand-in: an issue queue

Python Stand-in: prioritize open data quality issues

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Show that the fix worked

After a fix, watch the rule for a few cycles and confirm the failure rate stays low. Record what changed, so that if the problem returns you can see whether the prevention was removed or bypassed. Review recurring issues monthly with owners.

Do not "fix" quality by loosening the rule until it passes. If a target is truly wrong, change it openly with the owner's approval and a recorded reason.

Alerts that people act on

Each alert should answer: what failed, how badly, since when, which consumers are affected, who owns it and what to do first. Send it to the person or team who can act, not to a large mailing list. Group repeated failures so one broken feed does not create hundreds of messages. Review alerts that were ignored or closed without action, and either fix the rule, change the severity or remove it.

A worked example: a sudden drop

A fictional ticketing company sees daily bookings in its report fall by half. Before telling managers that sales collapsed, the team checks the signals in order. Freshness shows the load ran on time. Volume shows half the usual rows arrived. Schema shows no change. Distribution shows that all bookings from the mobile app are missing. Lineage points to a job that reads the app's export, which stopped writing after an app update renamed a folder.

Containment is a warning on the report. The immediate fix restores the folder path and reloads the missing days. The prevention is an agreement that app releases announce export changes, plus a per-channel volume check. Without the per-channel view, a smaller channel could have disappeared without anyone noticing.

Blame the process, not the person

When the cause involves a human mistake, keep asking why the mistake was easy to make and hard to notice. A confusing form, a missing check or time pressure are causes you can fix. People who expect blame hide problems, while people who expect improvement report them early.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. Why compare today's row count with a median of recent days?

    A median resists outliers, giving a steadier baseline.
  2. 2. What is containment in issue handling?

    Containment protects people while the cause is investigated.
  3. 3. When should you stop asking why?

    The goal is an actionable cause in a process or system, not blame.

Summary

  • Monitor freshness, volume, schema, distributions and rule results.
  • Scorecards should show trends, counts, targets and owners.
  • Treat problems as issues with severity, owner and due date.
  • Ask why until you reach a changeable cause, then prevent recurrence.
  • Verify fixes and never loosen rules quietly.

Next: Metadata and the Business Glossary

Seu progresso fica salvo neste navegador. Não precisa de conta.