teluzia.Cloud Engineer · Day 127
CHAPTER 19 · OBSERVABILITY AND RELIABILITY ENGINEERING

CloudWatch metrics/logs/alarms

4–5 hours including independent practice3 topics
LET’S MAKE THIS SIMPLE

What you’re learning today

CloudWatch separates three operational questions: what numerical behavior occurred, which events explain it, and when a condition deserves attention. Metrics answer the first through timestamped values, dimensions and statistics. Logs preserve individual events and correlation IDs. Alarms evaluate selected metric periods using a threshold and a missing-data rule. Today you will compare Average with Maximum, trace a structured 503 event, and hand-evaluate a three-out-of-five alarm. These are different views of the same incident: a five-minute average can look moderate even when three one-minute periods are dangerously high.

Think of it this way

A CloudWatch alarm is a smoke detector with a sampling rule: the temperature reading, event history and alarm decision are different pieces of evidence.

TOPIC 01 / 03Step by step

Metrics

A CloudWatch metric is a timestamped number identified by namespace, dimensions and statistic. Compare the same period and unit before interpreting CPU or request counts. For five one-minute CPU samples [20,30,90,95,92], the five-minute Average is 65.4%, while Maximum is 95%. A dimension such as InstanceId prevents mixing this instance with another.

WORKED EXAMPLE
For five one-minute CPU samples [20,30,90,95,92], the five-minute Average is 65.4%, while Maximum is 95%. A dimension such as InstanceId prevents mixing this instance with another.

A namespace groups metric names; a dimension identifies a series; a statistic reduces samples within a period. Suppose two instances report CPU, but one series has no recent sample. Select the intended InstanceId before comparing them, and distinguish no observation from a recorded zero. A one-minute period preserves bursts; a fifteen-minute aggregation can smooth them. Sum suits counts, while Average suits many level measurements, but units and sampling still matter. Percentiles need a compatible underlying metric distribution rather than an average of already averaged points. CloudWatch's timestamp and ingestion delay can also separate event time from visibility. Narrow dimensions give precise attribution; overly broad aggregation gives a simpler fleet overview with less ability to locate a failing instance. Retain the original sample resolution.

Why this matters

Averaging over five minutes can hide short CPU saturation; inspecting dimensions and Maximum avoids comparing unrelated instances or dismissing a real peak.

A common trap

Treating the 65.4% five-minute average as proof that CPU never exceeded 80% hides the three high one-minute samples.

MAKE IT VISIBLE

Explore an alarm decision

SAME DATA. DIFFERENT DECISION.

Will this CPU alarm fire?

Compare five synthetic one-minute samples with an M-of-5 alarm. Each sample represents one period here; real CloudWatch statistics may aggregate multiple observations within a period.

M-OF-5 ALARMALARM · 3 breaches
5-MINUTE AVERAGE65.4% · not above threshold
✦

The individual periods trigger this alarm even though the five-minute average stays below the threshold. Averaging can hide a burst. Missing-data policies, action routing, and recovery behavior still need configuration in a real alarm.

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

Metrics

A CloudWatch metric is a timestamped number identified by namespace, dimensions and statistic. Compare the same period and unit before interpreting CPU or request counts. For five one-minute CPU samples [20,30,90,95,92], the five-minute Average is 65.4%, while Maximum is 95%. A dimension such as InstanceId prevents mixing this instance with another.

WORKED EXAMPLE
For five one-minute CPU samples [20,30,90,95,92], the five-minute Average is 65.4%, while Maximum is 95%. A dimension such as InstanceId prevents mixing this instance with another.

A namespace groups metric names; a dimension identifies a series; a statistic reduces samples within a period. Suppose two instances report CPU, but one series has no recent sample. Select the intended InstanceId before comparing them, and distinguish no observation from a recorded zero. A one-minute period preserves bursts; a fifteen-minute aggregation can smooth them. Sum suits counts, while Average suits many level measurements, but units and sampling still matter. Percentiles need a compatible underlying metric distribution rather than an average of already averaged points. CloudWatch's timestamp and ingestion delay can also separate event time from visibility. Narrow dimensions give precise attribution; overly broad aggregation gives a simpler fleet overview with less ability to locate a failing instance. Retain the original sample resolution.

Why this matters

Averaging over five minutes can hide short CPU saturation; inspecting dimensions and Maximum avoids comparing unrelated instances or dismissing a real peak.

A common trap

Treating the 65.4% five-minute average as proof that CPU never exceeded 80% hides the three high one-minute samples.

Logs

Log groups hold streams of events. Retention controls storage duration; structured request IDs help correlate failures without recording tokens or personal data. A JSON event {"service":"orders","request_id":"r17","status":503,"duration_ms":820} supports filtering by status and joining related events by r17. The stream identifies its producer; the group supplies retention and access settings.

WORKED EXAMPLE
A JSON event {"service":"orders","request_id":"r17","status":503,"duration_ms":820} supports filtering by status and joining related events by r17. The stream identifies its producer; the group supplies retention and access settings.

An event timestamp describes when something happened; ingestion time describes when the logging system received it. Imagine a worker buffers two errors during a network interruption and submits them later. Ordering solely by ingestion could wrongly place the errors after recovery. Start with the service's event time, correlate the transaction identifier, and check clock synchronization before reconstructing causality. A log stream organizes a producer's sequence; a log group applies shared retention and permissions. Parse a stable field such as error_code instead of relying on a free-text sentence that changes between releases. Retention preserves a diagnostic window but increases stored data exposure and expense. Do not put credentials in a field merely because access to the log group is restricted. Check the producer clock.

Why this matters

A consistent request_id lets you connect the API failure to its downstream event without collecting private payloads or guessing from timestamps alone.

A common trap

Logging only "request failed" without service, status or request_id makes two simultaneous failures difficult to distinguish and encourages unsupported root-cause guesses.

Alarms

An alarm evaluates a metric over specified periods. Missing data treatment changes behavior; distinguish OK, ALARM and INSUFFICIENT_DATA before routing notifications. With threshold CPU>80%, three samples of the five exceed the threshold. A 3-of-5 rule can alarm while a five-minute-average threshold of 80% stays OK. Missing samples need an explicit policy.

WORKED EXAMPLE
With threshold CPU>80%, three samples of the five exceed the threshold. A 3-of-5 rule can alarm while a five-minute-average threshold of 80% stays OK. Missing samples need an explicit policy.

An evaluation period is one interval; evaluation periods define the lookback; datapoints-to-alarm specifies how many qualifying values are needed. Consider latency over a ten-minute incident: two high periods, one missing period and several healthy periods. A two-of-three alarm can behave differently from a consecutive-three alarm. First classify each available datapoint, then apply the selected missing-data treatment, then determine the state. Missing can mean collection failure rather than health, so use a separate telemetry-health signal when needed. An alarm transition does not guarantee notification delivery; verify the action destination and recipient separately. Short windows detect quickly but can be noisy, while longer windows delay detection. Describe that trade-off using user impact rather than choosing a threshold solely because it produces few alerts.

Why this matters

The evaluation rule determines whether a sustained burst pages an operator; changing period or missing-data behavior changes detection even when the raw samples stay identical.

A common trap

Using a five-minute-average threshold while describing the rule as three one-minute breaches implements a different detector and may suppress the expected alarm.

KEEP THESE WITH YOU

Today’s takeaways

Metrics: A CloudWatch metric is a timestamped number identified by namespace, dimensions and statistic.

Logs: Log groups hold streams of events.

Alarms: An alarm evaluates a metric over specified periods.

CLOSE THE LOOP

Ready to complete this day?

Verify the practical steps and pass the knowledge check (at least two thirds correct).

Lab steps verifiedKnowledge check passed