AWS Training
Modules Listen Certification

← Data Engineer IV — Role Review

Starts this lesson and continues through 8 more to the end of the course.

Monitoring pipelines with CloudWatch

A pipeline that fails silently is worse than one that fails loudly

A Glue job that errors out at 02:00 is a nuisance. A Glue job that succeeds with zero records read because the upstream partition never landed — unnoticed until Monday's Redshift report is empty — is a career event. The difference is entirely in what you alarm on.

What the posting is really asking. "Implement monitoring and alerting using CloudWatch for data pipeline health and performance" means: can you name the metrics Glue, Lambda, Redshift, Athena and Kafka actually publish, set an alarm with the right missing-data behaviour, catch job state changes with EventBridge, and extract structured metrics from logs — without paging a human for noise.

The metrics model

From CloudWatch concepts (verified 2026-10-30):

Concept Rule that matters
Namespace Container for metrics. There is no default namespace — every custom data point needs one. AWS namespaces follow AWS/<service> (e.g. AWS/Lambda, AWS/Athena).
Dimension Name/value pair that is part of the metric identity. Up to 30 dimensions per metric. Each unique combination is a separate metric; CloudWatch does not aggregate across dimensions you didn't publish.
Period Length of one statistic, in seconds. Valid values: 1, 5, 10, 30 or any multiple of 60. Default 60.
Statistics Aggregations over a period (Sum, Average, Min, Max, SampleCount, percentiles). Points with different units aggregate separately.
Resolution Standard = one-minute granularity (all AWS-service metrics). High-resolution = one second; only custom metrics, readable at 1/5/10/30 s periods. High-resolution alarms use 10 s or 30 s periods and cost more.

Retention — the trap

Data point period Kept for
< 60 s (high-res custom) 3 hours
60 s 15 days
300 s 63 days
3600 s 455 days (15 months)

Finer data is rolled up, not deleted: after 15 days 1-minute points are only retrievable at 5-minute resolution; after 63 days, hourly. Metrics with no new data expire after 15 months.

⚠️ A per-minute trend of last quarter's elapsedTime does not exist. Export with get-metric-data on a schedule, or accept hourly roll-ups.

Alarms

Alarm states (Alarm evaluation, verified 2026-10-30):

Evaluation Periods (N) and Datapoints to Alarm (M) give you "M out of N". The breaching points do not have to be consecutive — they just have to fall within the last N. The evaluation interval (period × evaluation periods) is capped at one day for periods under an hour and seven days for periods of an hour or more.

Missing data — the decision that makes or breaks pipeline alarms

From Configuring how alarms treat missing data (verified 2026-10-30):

TreatMissingData Behaviour Use for
notBreaching Missing = good Error-only metrics (Errors, numFailedTasks) that emit nothing when healthy
breaching Missing = bad "Heartbeat" metrics — a job that should report every run
ignore Keep current state Metrics with gaps you don't care about
missing (default) All points missing → INSUFFICIENT_DATA Rarely what you want for pipelines

⚠️ The default is missing. Glue only emits glue.driver.aggregate.* while a job is running. An alarm with the default setting on a job that never started will sit in INSUFFICIENT_DATA forever and never page. For "did my nightly load run at all?", use breaching.

Actions

A metric alarm can notify an SNS topic, perform EC2 or Auto Scaling actions, start a CloudWatch investigation, or create a Systems Manager OpsItem/incident (Using alarms). Actions fire only on state change (except Auto Scaling). Alarm history is kept 30 days. No limit on alarm count. CloudWatch does not validate that your SNS topic exists — a typo in the ARN is a silent non-page.

The CLI — copied from the docs

From the put-metric-alarm reference (verified 2026-10-30):

aws cloudwatch put-metric-alarm --alarm-name cpu-mon --alarm-description "Alarm when CPU exceeds 70 percent" --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period 300 --threshold 70 --comparison-operator GreaterThanThreshold  --dimensions "Name=InstanceId,Value=i-12345678" --evaluation-periods 2 --alarm-actions arn:aws:sns:us-east-1:111122223333:MyTopic --unit Percent

The same shape for a pipeline: swap --namespace Glue --metric-name glue.driver.aggregate.numFailedTasks --statistic Sum --dimensions Name=JobName,Value=<job> Name=JobRunId,Value=ALL Name=Type,Value=count and add --treat-missing-data notBreaching --datapoints-to-alarm 1. Both --treat-missing-data (breaching | notBreaching | ignore | missing) and --datapoints-to-alarm are documented parameters. Re-running the command with an existing name overwrites the alarm.

Test the wiring without waiting for a failure:

aws cloudwatch set-alarm-state --alarm-name cpu-mon --state-reason "initializing" --state-value ALARM

Composite alarms

A composite alarm's rule expression references other alarms' states — ALARM("x"), OK("y"), INSUFFICIENT_DATA("z") joined by AND, OR, NOT and parentheses (Create a composite alarm):

(ALARM("CPUUtilizationTooHigh") OR
ALARM("DiskReadOpsTooHigh")) AND
OK("NetworkOutTooHigh")

Composites can send SNS but cannot perform EC2 or Auto Scaling actions, and cross-account composites are not supported. Page once for "the pipeline is unhealthy", not five times.

Logs

Logs Insights

Commands include fields, filter, stats, sort, limit, parse, dedup, pattern, diff, unnest. Two from the examples page:

filter @message like /Exception/
    | stats count(*) as exceptionCount by bin(1h)
    | sort exceptionCount desc
fields @timestamp, @requestId, @message, @logStream
| filter @type = "REPORT" and @duration > 1000
| sort @timestamp desc
| dedup @requestId
| limit 20

Metric filters vs subscription filters

Metric filter Subscription filter
Does Turns matching log lines into a metric you can alarm on Streams matching events to Kinesis Data Streams, Lambda, Data Firehose, or OpenSearch
Quota per log group 100 (not adjustable) 5 (not adjustable)
Gotchas Not retroactive. Set a default value of 0 so the metric isn't "spotty" — but you can't set one if the metric has dimensions. At-least-once delivery, so duplicates can occur. Standard log class only. —

⚠️ A metric filter with dimensions and no default value produces missing data between matches — which brings you straight back to the TreatMissingData table above.

Embedded metric format (EMF)

Write a JSON log line with an _aws block and CloudWatch extracts metrics — no PutMetricData. From the specification (verified 2026-10-30):

{
  "_aws": {
    "Timestamp": 1574109732004,
    "CloudWatchMetrics": [
      {
        "Namespace": "lambda-function-metrics",
        "Dimensions": [["functionVersion"]],
        "Metrics": [
          {
            "Name": "time",
            "Unit": "Milliseconds",
            "StorageResolution": 60
          }
        ]
      }
    ]
  },
  "functionVersion": "$LATEST",
  "time": 100,
  "requestId": "989ffbf8-9ace-4817-a57c-e4dd734019ee"
}

Rules: Timestamp is epoch milliseconds, no more than 14 days past or 2 hours future; at most 100 MetricDefinitions per log event and 30 dimension keys per DimensionSet; every DimensionSet creates a new metric. When sending by PutLogEvents yourself, add the header x-amzn-logs-format: json/emf. Cleanest way to emit rows_written from a PySpark driver or a Lambda.

EventBridge: job and cluster state changes

Glue emits "detail-type":"Glue Job State Change" for SUCCEEDED, FAILED, TIMEOUT, STOPPED, and "Glue Job Run Status" for RUNNING/STARTING/STOPPING runs that exceed the job delay notification threshold (which you must set) — one event per run (Automating Glue with EventBridge). Delivery is best effort. Pattern from the EventBridge Glue reference:

{
  "source": ["aws.glue"],
  "detail-type": ["Glue Job State Change"]
}

⚠️ I could not verify a published sample payload for Glue Job State Change showing the exact detail field names — check events-ref-glue.html or capture a real event to a CloudWatch Logs target before filtering on detail.state.

EMR's sample payload is published (When to set up EMR events):

{
  "version": "0",
  "id": "999cccaa-eaaa-0000-1111-123456789012",
  "detail-type": "EMR Step Status Change",
  "source": "aws.emr",
  "account": "123456789012",
  "time": "2016-12-16T20:53:09Z",
  "region": "us-east-1",
  "resources": [],
  "detail": {
    "severity": "ERROR",
    "actionOnFailure": "CONTINUE",
    "stepId": "s-ZYXWVUTSRQPON",
    "name": "CustomJAR",
    "clusterId": "j-123456789ABCD",
    "state": "FAILED",
    "message": "Step s-ZYXWVUTSRQPON (CustomJAR) in Amazon EMR cluster j-123456789ABCD (Development Cluster) failed at 2016-12-16 20:53 UTC."
  }
}

EMR Cluster State Change has the same envelope with detail.state (e.g. WAITING) and stateChangeReason. Prefer events over polling DescribeStep.

The metrics each service actually publishes

Service Namespace Watch these Notes (verified 2026-10-30)
Glue Glue glue.driver.aggregate.numFailedTasks, .elapsedTime, .recordsRead, .bytesRead, .numCompletedTasks, .shuffleBytesWritten; glue.ALL.jvm.heap.usage Sent every 30 s. Dimensions JobName, JobRunId (or ALL), Type. Aggregate metrics are deltas — use SUM.
Lambda AWS/Lambda Errors, Throttles, Duration, IteratorAge, OffsetLag Throttles are not counted in Invocations or Errors. IteratorAge = age of the last record for Kinesis/DynamoDB/DocumentDB sources; OffsetLag for MSK/self-managed Kafka. Duration excludes cold start.
Redshift AWS/Redshift QueryDuration, WLMQueueLength, WLMQueueWaitTime, HealthStatus, PercentageDiskSpaceUsed, CommitQueueLength QueryDuration is in microseconds, 5-minute intervals, not on single-node clusters. HealthStatus runs a probe query every minute.
Kinesis AWS/Kinesis GetRecords.IteratorAgeMilliseconds, WriteProvisionedThroughputExceeded, ReadProvisionedThroughputExceeded, PutRecords.ThrottledRecords Iterator age of 0 = consumer fully caught up; alarm on Maximum.
MSK AWS/Kafka MaxOffsetLag, EstimatedMaxTimeLag, OfflinePartitionsCount, UnderReplicatedPartitions, KafkaDataLogsDiskUsed Consumer-lag metrics are per consumer group + topic.
Athena AWS/Athena TotalExecutionTime, QueryQueueTime, ProcessedBytes, EngineExecutionTime, DPUConsumed Per workgroup; ProcessedBytes is your cost proxy. aws cloudwatch list-metrics --namespace "AWS/Athena"

What to actually alert on

Batch pipeline (Glue / EMR / Lambda → Redshift / Athena)

Signal Source Missing data Why
Job FAILED / TIMEOUT / STOPPED EventBridge Glue Job State Change → SNS n/a Faster and more precise than any metric alarm
No successful run by deadline Custom EMF run_succeeded or recordsRead Sum, breaching breaching Catches the job that never started
recordsRead Sum below floor Glue breaching The "succeeded with zero rows" case
elapsedTime > p95 × 1.5 Glue notBreaching Stragglers before they hit the timeout
WLMQueueLength / WLMQueueWaitTime AWS/Redshift notBreaching Loads queueing behind BI traffic
PercentageDiskSpaceUsed > 80 AWS/Redshift notBreaching COPY fails hard at full disk
Errors > 0 (M of N = 1 of 1) AWS/Lambda notBreaching Error-only metric

Streaming pipeline (Kafka / Kinesis → Lambda / Glue streaming)

Signal Source Missing data Why
IteratorAge or MaxOffsetLag rising AWS/Lambda / AWS/Kafka breaching Consumer stopped: lag grows, metric vanishes
Throttles > 0 AWS/Lambda notBreaching Throttled invocations aren't Errors
OfflinePartitionsCount > 0, UnderReplicatedPartitions > 0 AWS/Kafka breaching Broker/cluster health
WriteProvisionedThroughputExceeded > 0 AWS/Kinesis notBreaching Producers being rejected
glue.driver.streaming.batchProcessingTimeInMs > trigger interval Glue breaching Micro-batches falling behind
Composite: lag AND (throttles OR errors) composite alarm — One page, not three

Quotas you will hit

From CloudWatch service quotas (verified 2026-10-30):

Quota Default Adjustable
PutMetricData requests/s 500 Yes
GetMetricData requests/s 500 Yes
DescribeAlarms requests/s 9 Yes
DeleteAlarms requests/s 3 No
Metrics Insights alarms 200 No
Alarm mute rules 2,000 No
Metric filters per log group 100 No
Subscription filters per log group 5 No
Log event size 1,024 KB No

⚠️ PutMetricData at 500/s per Region is per account, shared by every Glue executor and Lambda you own. EMF through logs sidesteps it entirely.

Pricing basics

From the pricing page (verified 2026-10-30): the free tier includes 10 custom/detailed metrics, 10 alarm metrics (standard resolution, direct metrics), 1 million API requests (excluding GetMetricData, GetInsightRuleReport, GetMetricWidgetImage, which are always charged), and 5 GB of Logs (ingestion, storage and Insights scan combined). Custom metrics are tiered per metric-month (first 10,000 / next 240,000 / next 750,000 / over 1,000,000); PutMetricData adds $0.01 per million requests. Alarms are per alarm metric per month (high-resolution and composite priced separately). Logs: per GB ingested, per GB-month stored, per GB scanned.

⚠️ I could not verify the dollar figures for the metric tiers, alarms, or Logs ingestion — the pricing page renders them client-side. Check aws.amazon.com/cloudwatch/pricing/ in a browser or use the AWS Pricing Calculator.

Check yourself

  1. Your Glue failure alarm has been INSUFFICIENT_DATA for three weeks and the job has failed twice. Why?
  2. Which Lambda metric tells you the Kinesis consumer is falling behind, and which statistic do you alarm on?
  3. You want one page when any of five stages fails. What do you build, and what can't it do?
  4. You need the number of Exception lines per hour as an alarmable metric from a log group that already has 100 metric filters. Options?
  5. Why is QueryDuration on a dev single-node Redshift cluster always empty?
  6. How long do you have 1-minute recordsRead data points?
Answers
  1. TreatMissingData defaults to missing. numFailedTasks is only emitted while the job runs, so between runs the alarm reverts to INSUFFICIENT_DATA; a brief failure spike may never satisfy the evaluation window. Use notBreaching with --datapoints-to-alarm 1, or alarm on the Glue Job State Change event instead.
  2. IteratorAge (milliseconds). Alarm on Maximum; a value of 0 means fully caught up. For MSK sources, OffsetLag.
  3. A composite alarm with ALARM("a") OR ALARM("b") ... and an SNS action. It cannot perform EC2 or Auto Scaling actions and cannot be cross-account.
  4. The 100-filter quota is not adjustable. Use a Logs Insights stats count(*) by bin(1h) query (a log alarm), or emit the count as EMF from the application, or route via a subscription filter to Lambda that publishes a metric.
  5. The docs state QueryDuration is not supported on single-node clusters.
  6. 15 days at 1-minute resolution; then 5-minute roll-ups to 63 days; then hourly to 455 days.

Teaching this section

← PreviousQuery and warehouse — Athena and RedshiftNext →Provisioning with Terraform