teluzia.Cloud Engineer · Day 54
CHAPTER 08 · AWS SCALING AND DATABASES

CloudWatch metrics, logs and alarms

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

What you’re learning today

Observe the application with metrics, logs and alarms that answer different questions. A metric measures a quantity over time, a log records events, and an alarm evaluates a metric condition. Your offline lab calculates a small window and exposes a wrong statistic that misses one important latency spike. CloudWatch metrics have a namespace, name, dimensions and timestamped values. Dimensions identify separate series rather than just decorating a graph. Period and statistic affect interpretation: average, sum and percentile answer different questions. Metric units and collection frequency should match the operational decision being made. CloudWatch Logs organizes events in log groups and streams with retention settings and access controls. Structured fields make investigation easier, but logging sensitive payloads increases risk. Correlation identifiers can connect requests across components. Log collection is not guaranteed merely because an EC2 instance or application exists.

Think of it this way

Metrics are gauges, logs are the event diary, and alarms are rules that decide when the gauge deserves attention.

TOPIC 01 / 03Step by step

Metrics, dimensions and statistics

CloudWatch metrics have a namespace, name, dimensions and timestamped values. Dimensions identify separate series rather than just decorating a graph. Period and statistic affect interpretation: average, sum and percentile answer different questions. Metric units and collection frequency should match the operational decision being made. Latency values 10, 10 and 1000 ms have average 340 ms; a threshold on average may behave differently from a threshold on maximum or a chosen percentile. Metric semantics prevent misleading dashboards and make alarms correspond to the actual user-visible risk rather than an arbitrary plotted number selected because it appears in a default console chart. Summing percentages or interpreting a request count average as a total changes meaning; choose the statistic according to the metric and record period and dimensions explicitly.

WORKED EXAMPLE
Latency values 10, 10 and 1000 ms have average 340 ms; a threshold on average may behave differently from a threshold on maximum or a chosen percentile.
Why this matters

Metric semantics prevent misleading dashboards and make alarms correspond to the actual user-visible risk rather than an arbitrary plotted number selected because it appears in a default console chart.

A common trap

Summing percentages or interpreting a request count average as a total changes meaning; choose the statistic according to the metric and record period and dimensions explicitly.

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, dimensions and statistics

CloudWatch metrics have a namespace, name, dimensions and timestamped values. Dimensions identify separate series rather than just decorating a graph. Period and statistic affect interpretation: average, sum and percentile answer different questions. Metric units and collection frequency should match the operational decision being made. Latency values 10, 10 and 1000 ms have average 340 ms; a threshold on average may behave differently from a threshold on maximum or a chosen percentile. Metric semantics prevent misleading dashboards and make alarms correspond to the actual user-visible risk rather than an arbitrary plotted number selected because it appears in a default console chart. Summing percentages or interpreting a request count average as a total changes meaning; choose the statistic according to the metric and record period and dimensions explicitly.

WORKED EXAMPLE
Latency values 10, 10 and 1000 ms have average 340 ms; a threshold on average may behave differently from a threshold on maximum or a chosen percentile.

Why this matters

Metric semantics prevent misleading dashboards and make alarms correspond to the actual user-visible risk rather than an arbitrary plotted number selected because it appears in a default console chart.

A common trap

Summing percentages or interpreting a request count average as a total changes meaning; choose the statistic according to the metric and record period and dimensions explicitly.

Logs and retention

CloudWatch Logs organizes events in log groups and streams with retention settings and access controls. Structured fields make investigation easier, but logging sensitive payloads increases risk. Correlation identifiers can connect requests across components. Log collection is not guaranteed merely because an EC2 instance or application exists. A JSON event with level, request_id, route and duration_ms can connect an HTTP error to a database timeout without storing a password or full customer request body. Structured limited logging improves diagnosis and cost control, while explicit retention prevents indefinite storage of noisy or sensitive records that were useful only for a bounded investigation. Assuming every instance automatically sends application logs overlooks agent and application configuration; verify arrival, timestamps and retention before relying on a log group during an incident.

WORKED EXAMPLE
A JSON event with level, request_id, route and duration_ms can connect an HTTP error to a database timeout without storing a password or full customer request body.

Why this matters

Structured limited logging improves diagnosis and cost control, while explicit retention prevents indefinite storage of noisy or sensitive records that were useful only for a bounded investigation.

A common trap

Assuming every instance automatically sends application logs overlooks agent and application configuration; verify arrival, timestamps and retention before relying on a log group during an incident.

Alarms and missing data

An alarm evaluates a metric over configured periods and datapoints, producing OK, ALARM or INSUFFICIENT_DATA states as applicable. Missing-data treatment changes behavior and should reflect whether silence is expected or itself a failure. An alarm action and a useful notification path must be configured and tested separately. A heartbeat alarm can treat missing data as concerning, while a sparse error-count metric may use a different policy; neither setting should be copied without understanding how the producer emits measurements. Deliberate missing-data policy avoids false reassurance or repeated noise and ensures an alarm is operationally useful, not simply present in the account with no verified route to the responsible person. Treating no data as zero for a required heartbeat hides a stopped producer; verify collection behavior and test the missing-data case alongside threshold breaches and notification delivery.

WORKED EXAMPLE
A heartbeat alarm can treat missing data as concerning, while a sparse error-count metric may use a different policy; neither setting should be copied without understanding how the producer emits measurements.

Why this matters

Deliberate missing-data policy avoids false reassurance or repeated noise and ensures an alarm is operationally useful, not simply present in the account with no verified route to the responsible person.

A common trap

Treating no data as zero for a required heartbeat hides a stopped producer; verify collection behavior and test the missing-data case alongside threshold breaches and notification delivery.

KEEP THESE WITH YOU

Today’s takeaways

Choose metric semantics carefully.

Verify structured log collection.

Test alarm data and notification paths.

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