This lesson combines 5 topics: Pipeline monitoring with CloudWatch and CloudTrail, AWS Glue Data Quality, Data Lineage and Observability, Data Pipeline Cost Optimization, Error Handling, Retry and Idempotency.
Learning Objectives
- Distinguish CloudWatch (metrics/logs/alarms) from CloudTrail (API audit)
- Memorize the key metrics for Glue, Kinesis, Lambda, Redshift
- Build alerting for pipelines: alarms, EventBridge, SNS
- Know Logs Insights and subscription filters for log pipelines
- Understand Glue Data Quality: rulesets, DQDL, the two run modes (catalog vs job)
- Write common DQDL rules
- Design a pipeline that "blocks bad data": quarantine, alert, fail-fast
- Know the other data quality options (DataBrew profile, Lambda validation, Deequ)
- Understand what data lineage is and which problems it solves
- Know the lineage/catalog tools on AWS: SageMaker Catalog (DataZone), Glue, OpenLineage
- Master the data observability framework: freshness, volume, schema, quality, lineage
- Design versioning/audit for datasets
- Master the pricing model of each layer: storage, ingestion, compute, query
- Memorize the top cost levers by service (the "cheat" table)
- Know the tracking tools: Cost Explorer, Budgets, CUR, tags
- Solve "most cost-effective" questions with an analysis framework
- Systematize retry/DLQ mechanisms for each service in a pipeline
- Understand delivery semantics: at-least-once is the default → you must be idempotent
- Master idempotent write techniques for each data store
- Design a "recoverable" pipeline: checkpoint, backfill, reprocess
Part 1: Pipeline monitoring with CloudWatch and CloudTrail
1. CloudWatch vs CloudTrail — division of roles
| CloudWatch | CloudTrail | |
|---|---|---|
| Question it answers | "How is the system performing?" (metrics, logs, alarms) | "Who did what, and when?" (API calls) |
| Data | Time-series metrics, log events | Events recording every API call (console/CLI/SDK) |
| Use case | Performance, alerting, dashboards | Audit, security investigation, compliance |
| Retention | Metrics 15 months; Logs per retention setting | 90 days of event history; longer → trail to S3 |
"Find out who deleted a Glue table / changed a bucket policy" → CloudTrail. "Job is slow/failing, alert" → CloudWatch.
2. Metrics to memorize by service
| Service | Metric | Meaning when abnormal |
|---|---|---|
| Kinesis | GetRecords.IteratorAgeMilliseconds | Consumer falling behind |
| Kinesis | Write/ReadProvisionedThroughputExceeded | Not enough shards / hot shard / missing EFO |
| Lambda | Errors, Throttles, Duration, IteratorAge | Code errors, insufficient concurrency, near timeout |
| Glue | glue.driver.aggregate.numFailedTasks, memory/CPU per executor | Task failures, insufficient memory |
| Firehose | DeliveryToS3.Success, ThrottledRecords | Destination errors, overload |
| Redshift | QueryDuration, WLMQueueLength, CPU, PercentageDiskSpaceUsed | Queue congestion, running out of disk |
| SQS | ApproximateAgeOfOldestMessage | Consumer cannot keep up |
| DMS | CDCLatencySource/Target | Replication lag |
3. Standard alerting pattern for pipelines
- Composite alarm: combines several alarms to reduce noise
- Alarm on a math expression: e.g. error rate = Errors/Invocations
- Step Functions: a
Catchstate → SNS right inside the workflow (proactive) + an EventBridge rule onExecution Status Change(safety net)
4. CloudWatch Logs for data pipelines
- Glue continuous logging, Lambda logs, Redshift audit logs... all flow into Logs
- Logs Insights: query logs with its own language (
fields,filter,stats) — fast job error investigation - Subscription filter: stream logs in real time → Kinesis/Firehose/Lambda/OpenSearch (logs themselves are also a data pipeline!)
- Retention: never expires by default — set retention and/or export to S3 to reduce cost (a frequently tested cost point)
5. CloudTrail details worth remembering
- Management events (default): control plane — CreateTable, PutBucketPolicy...
- Data events (enabled separately, extra cost): data plane —
s3:GetObject,lambda:Invokeper resource → investigate "who read which object" - A trail continuously writes to S3 (+ CloudWatch Logs); organization trail for multi-account
- CloudTrail Lake: query events with SQL (no need to build Athena on top of a trail yourself)
- Athena querying trail logs on S3: the classic audit analysis pattern
Part 2: AWS Glue Data Quality
1. Why you need a data quality gate
Bad data (abnormal nulls, duplicate keys, schema drift, out-of-domain values) that slips into curated/warehouse → wrong reports, broken models, very expensive fixes. Principle: block it at the gate (before writing to curated), not discover it on a dashboard.
2. AWS Glue Data Quality
Two modes
| Mode | Runs on | Use when |
|---|---|---|
| Data Catalog (at-rest) | Tables in the catalog — evaluated on a schedule/on demand | Periodic checks of existing datasets |
| In a Glue ETL job (in-transit) | A DynamicFrame mid-pipeline (the EvaluateDataQuality transform) | A gate in the pipeline — decides whether to continue writing or block |
- Built on the open-source Deequ (Spark)
- Recommendations: Glue scans the data and suggests a starter ruleset — saves hand-writing
- Output: score + pass/fail per rule; emits EventBridge events, pushes CloudWatch metrics → alerting
- In a job: split failing records (
rowLevelOutcomes) → write to a quarantine location
DQDL — Data Quality Definition Language
Rules = [
RowCount > 1000,
IsComplete "customer_id", # not null
IsUnique "order_id", # no duplicates
ColumnValues "status" in ["NEW","PAID","CANCELLED"],
ColumnValues "amount" between 0 and 1000000,
Completeness "email" > 0.95, # ≥95% not null
ColumnLength "country_code" = 2,
Mean "amount" between 50 and 500,
ReferentialIntegrity "customer_id" "dim_customers.id" = 1.0,
DataFreshness "updated_at" <= 24 hours
]
Dynamic rules based on history: RowCount > avg(last(10)) * 0.5 — detects "today's data is abnormally small" (anomaly-style).
3. Pipeline pattern: DQ gate + quarantine
- Fail-fast: if an overall rule fails (e.g. RowCount too low) → the job fails → a Step Functions Catch stops the pipeline, so bad data never overwrites good data
- Row-level: sporadic errors → split into quarantine, the clean part continues — the pipeline does not die because of a few bad records
4. Related options (to distinguish in the exam)
| Tool | Role |
|---|---|
| Glue Data Quality | Rule-based DQ for the lake/Glue pipelines — the default DEA answer |
| Glue DataBrew profile | Statistical profiling + anomaly detection through a UI for analysts |
| Lambda validation | Lightweight per-file/per-record checks at the edge (schema, format) |
| Self-managed Deequ on EMR | When you run Spark yourself — more effort |
| Schema Registry | Blocks bad schemas at the streaming layer (not data values) |
Part 3: Data Lineage and Observability
1. Data lineage
Lineage = the trail of where data came from and how it was transformed: which source a table was produced from, through which job, and who consumes it.
It answers questions such as:
- Impact analysis: if the source table schema changes, which downstream assets break?
- Root cause: the dashboard is wrong — at which step did the data go bad?
- Compliance: where has this PII data flowed to?
2. Tools on AWS
| Tool | Lineage role |
|---|---|
| Amazon DataZone / SageMaker Catalog (the new generation, DataZone is being unified into Amazon SageMaker) | Business data catalog: organizes data domains, publish/subscribe datasets between teams, automatically captures lineage (integrates the OpenLineage standard), search + governance |
| Glue Data Catalog | Technical metadata (schema/location) — not full lineage |
| OpenLineage (open standard, integrates with Spark/Airflow) | Emits lineage events from jobs — MWAA/Glue can integrate |
| Step Functions/Glue Workflows | Shows job relationships, not table/column-level lineage |
| SageMaker ML Lineage | Lineage for ML artifacts |
Exam level: know that DataZone/SageMaker Catalog = catalog + governance + lineage for multi-team organizations; Glue Catalog = technical metadata. "Business users find and understand datasets, track their origin" → DataZone/SageMaker Catalog.
3. Data observability — 5 pillars
| Pillar | Question | How to do it on AWS |
|---|---|---|
| Freshness | Is the data up to date? | DQ DataFreshness, alarm on the time of the latest partition |
| Volume | Is the row count normal? | DQ RowCount vs avg(last N), row count metric per run |
| Schema | Has the structure changed? | Crawler change policy, Schema Registry compatibility, schema drift alerts |
| Quality | Are the values valid? | Glue DQ rules (yesterday) |
| Lineage | Where from, where to? | DataZone/OpenLineage |
Combined with Part 1 (Monitoring): metrics/alarms are the infrastructure; these 5 pillars are "what needs to be measured" specifically for data.
4. Dataset versioning and audit
- S3 Versioning: keeps object versions — recover from accidental overwrites/deletes (with MFA delete for important buckets)
- Iceberg time travel + snapshots: query "the data as of time T", roll a table back to a snapshot — table-level change audit
- An immutable raw zone (append only) is itself the lake's natural form of versioning
- Glue schema version history in the catalog; Schema Registry keeps streaming schema versions
Part 4: Data Pipeline Cost Optimization
1. Cost by pipeline layer
STORAGE S3 (class, lifecycle, small files) | Redshift storage | log retention
INGEST Kinesis (shard/GB) | Firehose (GB) | DMS instance | AppFlow run
COMPUTE Glue (DPU-h) | EMR (EC2/Spot) | Lambda (GB-s) | Flink (KPU-h)
QUERY Athena ($/TB scan) | Redshift (node/RPU) | Spectrum ($/TB)
TRANSFER cross-region, NAT gateway, Internet egress
2. Top cost levers by service (a must-memorize table)
| Service | Cost reduction levers |
|---|---|
| S3 | Lifecycle → IA/Glacier; Intelligent-Tiering for unknown patterns; merge small files; delete incomplete multipart uploads; S3 Storage Lens |
| Athena | Parquet + partitions + column selection (less scanning); result reuse; workgroup limits |
| Glue | Flex; Auto Scaling; bookmarks (incremental); Python shell for small tasks; newer versions; timeouts |
| EMR | Spot for task nodes; transient clusters; Graviton; managed scaling; S3 instead of HDFS |
| Redshift | Serverless for intermittent use; Reserved for 24/7; Spectrum for cold data; pause/resume (provisioned dev) |
| Kinesis | Provisioned for steady traffic (cheaper than on-demand); KPL aggregation (fewer PUT payload units) |
| Lambda | Right-size memory; Graviton (arm64); larger batches |
| CloudWatch Logs | Set retention; Infrequent Access log class; cut unnecessary logs |
| DynamoDB | On-demand ↔ provisioned matched to the pattern; TTL to clean up data; Standard-IA table class |
| NAT/transfer | Free gateway endpoints (S3/DynamoDB) instead of NAT for S3 traffic; process in the same region |
3. Cost management tools
| Tool | Purpose |
|---|---|
| Cost Explorer | View/analyze cost by service, tag, time; forecast |
| AWS Budgets | Thresholds + alerts (SNS/email); budget actions |
| CUR (Cost and Usage Report) / Data Exports | Line-item detail delivered to S3 — query with Athena (a cost analysis pipeline!) |
| Cost allocation tags | Tag resources by team/project → cost per team (activate in Billing) |
| Compute Optimizer / Trusted Advisor | Right-sizing recommendations |
4. Framework for solving "most cost-effective" questions
- Reduce the data you touch: compression, columnar, partitions, incremental — the biggest lever, applies to every layer
- The right tool for the frequency: intermittent → serverless (Athena, Glue, Redshift Serverless); continuous and steady → provisioned/reserved
- The right tier for the temperature: hot/warm/cold — S3 classes, UltraWarm, Spectrum
- Cheap capacity when interruption is tolerable: Spot, Flex
- Do not forget hidden costs: NAT gateway, cross-region, logs without retention, crawlers running unnecessarily, idle clusters
Exam trap note: "most cost-effective" must still meet the functional requirements first — the cheapest answer that misses the SLA/latency is wrong.
5. Quick analysis example
Pipeline: Firehose → S3 (JSON, not partitioned) → Athena dashboard every 15 minutes → nightly Glue with a fixed 20 DPU → Glue logs kept forever.
Fix: enable Firehose Parquet conversion + dynamic partitioning → Athena scanning drops ~90%; enable result reuse for the dashboard; enable Glue Auto Scaling + Flex + bookmarks; CloudWatch Logs 30-day retention; S3 lifecycle raw → IA/Glacier. No architecture change, and most of the cost goes away.
Part 5: Error Handling, Retry and Idempotency
1. Delivery semantics — the foundational truth
| Semantics | Meaning | AWS reality |
|---|---|---|
| At-most-once | May lose, no duplicates | Rarely used for data |
| At-least-once | No loss, may duplicate | The default for S3 events, SQS standard, Kinesis, Lambda retry, DMS... |
| Exactly-once | No loss, no duplicates | Only within supported scopes: Flink checkpoints, Kafka transactions, FIFO dedup — end to end you must design it yourself with idempotency |
→ The mantra: "assume duplicates, design idempotent".
2. Retry and DLQ by service (summary table)
| Service | Failure mechanism |
|---|---|
| Lambda async (S3/SNS event) | Retries 2 times → on-failure destination / DLQ |
| Lambda + SQS | Message returns to the queue (visibility timeout) → maxReceiveCount → SQS DLQ; partial batch response |
| Lambda + Kinesis | Retries block the shard → configure max retry, bisect batch, on-failure destination |
| Step Functions | Retry (backoff, maxAttempts) + Catch per state — the hub for error orchestration |
| Glue job | MaxRetries on the job; bookmark commits only on success |
| Firehose | Retries the destination → S3 error/backup prefix — no data loss |
| EventBridge | Retries for 24h → DLQ (SQS) per target |
| SQS | Redrive policy → DLQ; redrive back from DLQ → source after fixing |
General principle: every async point must have a "landing spot" (DLQ/error prefix) + an alarm on that landing spot.
3. Idempotency by data store
| Store | Idempotent write technique |
|---|---|
| S3 | Write to a deterministic key (same input → same path, PUT overwrites); write with partition overwrite instead of append |
| Iceberg | MERGE INTO on a key — rerunning creates no duplicates |
| Redshift | Staging table + DELETE ... USING staging then INSERT (upsert pattern), or MERGE; no blind appends |
| DynamoDB | Conditional write (attribute_not_exists), idempotency key table |
| OpenSearch | Index with a deterministic document _id — rewriting is an update |
| General | Idempotency key from the event id; a "processed" marker table (DynamoDB + TTL) |
4. Checkpoint / restart / backfill
- Built-in checkpoints: Glue bookmarks, KCL leases (DynamoDB), Flink checkpoints, Spark streaming checkpoints, DMS task position — understand when each one commits (usually: after success → the unfinished part reruns → you need an idempotent sink)
- Backfill/reprocess: design jobs to accept time range/partition parameters so you can rerun a range (combined with pausing the bookmark); an immutable raw zone is the precondition for safe reprocessing
- Poison record: one bad record must not kill the pipeline — bisect/DLQ/quarantine it and handle it separately
5. Checklist for designing a fault-tolerant pipeline
- Every async consumer has a DLQ/on-failure destination + an alarm on DLQ depth
- Idempotent sinks (per the table in section 3)
- Retries with backoff + jitter, bounded (no infinite retries)
- Checkpoints in the right place; understand the semantics of a mid-run failure
- Parameterized jobs to backfill by partition range
- Timeouts on every job/step (Step Functions
TimeoutSeconds, Glue timeout) - Classify errors: transient (retry) vs permanent (straight to DLQ, do not retry for 24h)
Review Questions
-
You need to know who DROPped a table in the Glue Data Catalog last week. What do you use?
Show answer
CloudTrail: look for the
DeleteTableevent (a management event) in Event history (90 days) or query the trail on S3/CloudTrail Lake — you see the identity, time, and source IP. CloudWatch does not record "who called which API". -
A Kinesis → Lambda pipeline occasionally falls "silently" 30 minutes behind. How do you set up alerting?
Show answer
A CloudWatch Alarm on the stream's
GetRecords.IteratorAgeMilliseconds(e.g. > 5 minutes for 3 consecutive datapoints) → SNS. Add alarms on LambdaErrors/Throttles, because lag is usually caused by repeated errors or insufficient concurrency. Iterator age is the "golden metric" for consumer latency. -
You want to be notified of every Glue job FAILED and Step Functions execution FAILED in the account. What is the simplest way?
Show answer
EventBridge rules: (1) pattern
source: aws.glue, detail.state: FAILED→ SNS; (2) patternsource: aws.states, detail.status: FAILED→ SNS. The services emit the events themselves — no changes to jobs/workflows, and it covers the whole account. This is the "notification on failure, no code change" pattern. -
Count the log lines containing "ERROR" in a Glue log group and alert when there are > 10 in 5 minutes. How?
Show answer
A metric filter on the log group (pattern
ERROR) produces a custom metric → a CloudWatch Alarm with a threshold of 10/5 minutes → SNS. Logs Insights is for manual investigation, while a metric filter is how you turn logs into automatic alerts. -
An audit requirement asks "who read the objects in the PII bucket" — what do you configure, and what about cost?
Show answer
Enable CloudTrail data events for S3 (select just the PII bucket, read events
GetObject) — default management events do NOT record the data plane. Data events are billed per event, so busy buckets get expensive — enable them only on the buckets that need auditing. Query with Athena/CloudTrail Lake. (S3 server access logs are a cheaper option but less detailed, with best-effort delivery.) -
Requirement: before writing to curated, ensure order_id has no duplicates, customer_id is not null, amount is within a valid range; violating records are kept for investigation. Design?
Show answer
In the Glue ETL job, add the EvaluateDataQuality transform with DQDL:
IsUnique "order_id",IsComplete "customer_id",ColumnValues "amount" between .... Use row-level outcomes to split failing records into a quarantine S3 prefix, while passing records go to curated. DQ results are pushed to CloudWatch/EventBridge to alert when the error rate is high. -
How do you automatically detect "today's source file is only 1/10 of the usual size"?
Show answer
Use a DQDL rule that compares with history:
RowCount > avg(last(10)) * 0.5(or DataFreshness for data latency) — Glue DQ stores the results of previous runs for comparison. Rule fails → EventBridge → SNS + stop the workflow. This is exactly Glue DQ's built-in form of anomaly detection. -
Should you hand-write a ruleset from scratch for a 200-column table? Is there a faster way?
Show answer
Use rule recommendations: Glue DQ scans the table and proposes a ruleset (completeness, uniqueness, min/max, data types) based on the actual data — then you hand-tune the business rules. Faster and less error-prone than writing 200 columns manually.
-
What is the difference between failing the whole job fast and row-level quarantine — when do you use which?
Show answer
Fail-fast (the job fails when the ruleset fails): for systemic errors — broken schema, half the data missing, a broken source — continuing only damages downstream. Row-level quarantine: for sporadic errors — a few records missing fields — isolate the bad part while the clean part is still delivered within the SLA. Mature pipelines use both: an overall fail-fast threshold + splitting out bad rows below the threshold.
-
For quality control at the Kafka/Kinesis streaming layer — which tool fits better than Glue DQ?
Show answer
Glue Schema Registry — enforces schema and compatibility right at the producer/consumer (blocking structurally invalid messages from the start). Abnormal data values in a stream: validate in Lambda/Flink. Glue DQ targets batch/at-rest datasets and Glue jobs (Glue streaming jobs do support DQ, but the schema gate at the registry is still the first layer).
- Before changing the type of a column in a source table, you need to know every table/dashboard affected. Which capability and which tool?
Show answer
Data lineage — impact analysis. On AWS: Amazon DataZone / SageMaker Catalog (captures lineage automatically via OpenLineage from Glue/Spark/Airflow) lets you trace the downstream graph from the source table to dashboards. The Glue Catalog on its own only has schema/location, with no dependency graph.
- This morning's dashboard shows revenue as 0. What is the investigation sequence using the observability framework?
Show answer
(1) Freshness — did the latest partition/data arrive (did the job run?); (2) Volume — the latest run's row count compared with normal; (3) Quality/Schema — DQ results, schema drift causing bad parsing; (4) Lineage — trace back from dashboard → table → job → source to find the broken link. With freshness/volume alarms in place, you would have known before the business noticed.
- Many teams need an internal "data marketplace": find datasets, understand their meaning, request access through a process. Which service?
Show answer
Amazon DataZone (SageMaker Catalog) — a business catalog: producers publish datasets with business metadata, consumers search and subscribe (approval workflow), and permissions are granted automatically through Lake Formation underneath. The Glue Catalog is technical metadata for engines, with no search/subscribe experience for business users.
- A job accidentally overwrote yesterday's curated data. Name two mechanisms that allow a quick recovery.
Show answer
(1) S3 Versioning — overwritten objects keep their previous version; restore by deleting the new version/copying the old one; (2) if it is an Iceberg table: time travel/rollback to a previous snapshot (FOR TIMESTAMP AS OF, rollback snapshot) — one command, table level. This is why important curated data should have versioning enabled or use a table format.
- How do you detect schema drift from a source before it breaks the pipeline?
Show answer
Batch: a crawler with a schema change policy (log/update) + comparing schema versions in the catalog, alerting via EventBridge on change; or DQ rules ColumnCount/ColumnExists. Streaming: Glue Schema Registry with a compatibility mode — an incompatible new schema is rejected right at the producer and never enters the stream. Preventing it at the gate is always cheaper than fixing it downstream.
- The S3 bill keeps rising even though useful data is not growing. Name three common suspects and how to deal with them.
Show answer
(1) No lifecycle — old data still sits in Standard: add rules to transition to IA/Glacier/delete; (2) incomplete multipart uploads and noncurrent versions (bucket versioning) pile up: lifecycle rule AbortIncompleteMultipartUpload + expire noncurrent versions; (3) small files/intermediate copies left behind by jobs: clean temp prefixes, run compaction. Use S3 Storage Lens to find where it is bloating.
- Athena bills $3,000/month for repeated dashboards over JSON. What is the cost reduction plan in order of impact?
Show answer
(1) CTAS to convert to Parquet + partition — cuts scanning by ~90% (the biggest impact); (2) result reuse for repeated dashboards — runs within the TTL do not scan; (3) materialize aggregates into small tables and have the dashboard query those; (4) workgroup data usage controls to block runaway queries. If dashboards are very frequent → consider moving the BI layer to Redshift.
- When is Kinesis provisioned cheaper than on-demand, and which producer technique reduces PUT cost?
Show answer
Provisioned is cheaper when throughput is steady and predictable — the fixed shard-hour cost is lower than on-demand's per-GB charges at continuously high utilization (on-demand charges a premium for flexibility). Producer: KPL aggregation packs small records together — Kinesis bills PUT payload in 25KB units, so packing many small records into one PUT significantly reduces the number of payload units.
- You want cost to be visible per data product/team. What do you set up?
Show answer
(1) Standardize tagging (e.g. team, data-product) on every resource (job, bucket, cluster, stream); (2) activate cost allocation tags in the Billing console; (3) view by tag in Cost Explorer and set Budgets per team; (4) for deeper detail: CUR/Data Exports into S3 + Athena/QuickSight — itself a data pipeline for FinOps.
- A Glue job in a private VPC subnet reads/writes S3 through a NAT gateway and incurs large processing charges. How do you eliminate them?
Show answer
Create an S3 Gateway VPC endpoint (free, add a route to the route table) — S3 traffic stays inside AWS without going through NAT ($/GB). Similarly, DynamoDB has a free gateway endpoint. Other APIs (Glue, KMS, CloudWatch) use interface endpoints (hourly charges, but usually still cheaper than NAT at high volume).
- A nightly Glue job fails at 2 a.m. after writing half its output to S3 (append). Rerunning produces duplicate data. How do you fix the design?
Show answer
Make the sink idempotent: (1) write with partition overwrite — the job overwrites the whole partition for that day instead of appending (rerun = clean overwrite); or (2) switch to an Iceberg table + MERGE INTO on a key; or (3) write to a staging prefix and only move/commit on success. Also understand that with bookmarks, the failed part will be read again (at-least-once).
- An SQS → Lambda pipeline occasionally gets permanently failing messages (corrupt data). Requirements: no message loss, no queue blockage, alerting. Design?
Show answer
A redrive policy with maxReceiveCount (e.g. 3) → bad messages go to the DLQ; a CloudWatch alarm on the DLQ's ApproximateNumberOfMessagesVisible → SNS; after fixing the code/data, use DLQ redrive to push them back to the source queue. Combine with partial batch response so good messages in the same batch are not retried needlessly.
- You load incrementally into Redshift every hour, and source files are sometimes resent (duplicates). What is the deduplicating load pattern?
Show answer
Staging + upsert: COPY into a staging table, then in one transaction DELETE FROM target USING staging WHERE matching keys + INSERT INTO target SELECT ... FROM staging (or use MERGE). However many times you rerun it, the result is still correct — idempotent. Appending COPY directly into the target is the root cause of duplicates.
- Distinguish transient and permanent errors — why must the retry strategies differ?
Show answer
Transient (throttling, network timeouts, temporary service errors): retrying with exponential backoff + jitter usually resolves them. Permanent (corrupt data, wrong schema, AccessDenied): retrying only burns resources and delays — you must fail fast to a DLQ/quarantine and alert. In Step Functions: declare Retry for transient ErrorEquals, and Catch for the remaining errors routing to a handling branch.
- You need to rerun the pipeline for just 2026-07-01 after discovering a transform bug. Which design conditions make this safe?
Show answer
(1) An immutable raw zone still holds the original data for that day; (2) the job is parameterized by partition (--date 2026-07-01) instead of "process whatever is new"; (3) the sink is idempotent per partition (overwrite/MERGE) so rewriting creates no duplicates; (4) the bookmark is paused, or a separate backfill path does not break the incremental state. Without these conditions, a backfill becomes a new source of errors.
Hands-on Exercises
Part 1: Pipeline monitoring with CloudWatch and CloudTrail
- Create an IteratorAge alarm for the Week 1 Day 3 lab stream → SNS email
- Create an EventBridge rule Glue FAILED → SNS, run a deliberately failing job to test it
- Use Logs Insights to query Lambda logs: count errors per 5 minutes
- Enable CloudTrail data events for 1 bucket and watch GetObject events appear
Part 2: AWS Glue Data Quality
- Generate a ruleset recommendation for the curated table from the previous lab and review the suggested rules
- Write 6 DQDL rules for an orders table (RowCount, IsUnique, IsComplete, ColumnValues, Completeness, DataFreshness)
- Add EvaluateDataQuality to a Glue Studio job with a quarantine branch
- Read DQDL reference
Part 3: Data Lineage and Observability
- Draw a lineage diagram for your lab pipeline from source to Athena
- Enable S3 Versioning on the curated bucket, try overwriting + restoring an object
- With the Iceberg table from Week 2 Day 1: run a time travel query and view the list of snapshots
- Read Amazon DataZone
Part 4: Data Pipeline Cost Optimization
- Open Cost Explorer, group by service — identify the 3 most expensive data services in the lab account
- Create a $10 Budget with an SNS alert
- Write a complete lifecycle policy for the raw bucket: 30d → IA, 180d → Glacier, abort multipart 7d, expire noncurrent 30d
- Set 30-day retention on all lab log groups
Part 5: Error Handling, Retry and Idempotency
- Add a DLQ + alarm for a Lambda event source in the lab
- Write the staging-upsert pattern (SQL) for a Redshift orders table
- Update the lab Glue job: accept a
--process_dateparameter and overwrite the corresponding partition - Read Exponential backoff and jitter (AWS builders' library)
References
- CloudWatch concepts
- Monitoring Glue with CloudWatch metrics
- CloudTrail concepts
- CloudWatch Logs Insights
- AWS Glue Data Quality
- Data Quality in Glue ETL jobs
- DQDL
- Amazon DataZone
- Data lineage in DataZone
- OpenLineage
- Iceberg time travel (Athena)
- S3 lifecycle configuration
- AWS Cost Explorer
- Cost and Usage Reports / Data Exports
- Athena cost controls
- SQS dead-letter queues
- Step Functions error handling
- Lambda event source mapping error handling
- Redshift MERGE