Instrumenting a Pipeline E2E

Concepts covered: Pipeline Monitoring

Take orders_daily as it stood before this lesson: 6 tasks on a daily schedule, failure emails to a shared inbox, no metrics or lineage, and no tags or CI. Instrumenting all of it in 1 project takes a quarter and pays nothing until the end. Sequencing it so each step works on its own gives the team a better pipeline every week, and a point to stop at whenever priorities shift.

7 steps, each useful alone

WeekStepValue on its ownBuilds on
1Freshness and row-count check on `agg_daily_revenue` at 07:00 UTC, paging the ownerThe team hears about a late or short load before Finance's 08:00 UTC reviewNothing
2`run_id` on every log line from every taskA single search returns a failed run's whole storyThe week 1 page links to the run
3Duration and row metrics per task, labelled `pipeline` and `task`Shows which task slowed down or shrank, and since when`run_id` links a metric spike to the run's logs
4Quality gates at the `stg_payments` and `stg_orders` boundariesBad batches stop before they reach `fct_orders`Week 3 metrics: block below 50% of the trailing average, tighten after a few weeks
5Lineage from parsed code and 30 days of query logsEvery page names the downstream nodes and their ownersWeek 1 pages now carry the blast radius
6Query tags on every taskCost per run and per task on the monthly rollupWeek 2 `run_id` joins a costly query to its run's logs
7Slim CI with the 4 test layersBroken changes stop at the pull requestWeek 5 lineage picks the build set; week 4 gates run in layer 3

The order follows the questions an incident raises: is something wrong, where, who is affected, what is it costing, and how do we stop the next one. Detection goes first because every later step assumes the team knows a failure happened. CI comes last here even though it prevents incidents, because slim selection needs lineage and layer 3 needs the gates.

orders_daily after week 7. Every task sends tagged queries and logs with the run's run_id; the gate holds bad staging batches, and the final task carries Finance's freshness promise.
  • extract_payments (transform, orchestrator); retries: 3; backoff: exponential, 30s base
  • extract_orders (transform, orchestrator); retries: 3; backoff: exponential, 30s base
  • stg_payments (transform, orchestrator); idempotency: overwrite date partition
  • stg_orders (transform, orchestrator); idempotency: overwrite date partition
  • staging_gate (quality gate, orchestrator); on error: block downstream, page owner
  • build_fct_orders (transform, orchestrator); parallelism: 32 partitions; backfill: rebuild by date in lineage order
  • build_agg_daily_revenue (transform, orchestrator); freshness: ready by 07:00 UTC; alerting: page payments-data if late or short
  • Revenue dashboard (consumer, Finance)
  • extract_payments -> stg_payments
  • extract_orders -> stg_orders
  • stg_payments -> staging_gate
  • stg_orders -> staging_gate
  • staging_gate -> build_fct_orders
  • build_fct_orders -> build_agg_daily_revenue
  • build_agg_daily_revenue -> Revenue dashboard
Do
  • Ship each step to prod before starting the next
  • Alert on the output table first and on task failures second
  • Reuse run_id as the key that joins logs to tags, and to pages too
  • Set gate thresholds from the metric history you already collect
Avoid
  • Start with CI on a pipeline whose failures nobody sees
  • Label metrics with run_id or order_id, or with partition_date
  • Rely on engineers to type query tags by hand in each task
  • Roll out all 7 steps as 1 change at the end of the quarter

Another team asks for help instrumenting clickstream_sessions, the $11,800-a-month hourly pipeline with 3 readers. Failures are rare; the bill is the complaint. Which first 2 steps fit?

Practice across all 5 sections

In week 9 the 07:00 UTC check pages: agg_daily_revenue has no partition for 2026-10-23. The page links run orders_daily__2026-10-23T06:00. The staging gate passed, and logs show build_fct_orders still running at 50 minutes, against the 12 its duration metric shows on a normal day. Its tagged queries have already cost 3 times a normal run, and the only change since the last good run is a merge on 2026-10-22. Which response uses the instrumentation best?

About this lesson

This section is part of the Pipeline Operations: Intermediate lesson on DataDriven, the home of data engineering. Lessons cover SQL, Python, Spark, data modeling and pipeline architecture, and each section pairs its explanation with worked examples and practice you run as you go.