Volume 6 · Chapter 7 — Observability and Operations

CloudWatch in Depth: Metrics, Agent, Alarms, and Automation

Goutham Mayaluri 4 min read AWSCloudCloudWatchObservability

7.1 Introduction

CloudWatch is far richer than the fundamentals chapter conveyed. The exam expects knowledge of custom metrics and the CloudWatch agent, metric math and anomaly detection, composite alarms, and - importantly - theactionsalarms can take to automate responses (Auto Scaling, EC2 recovery, SSM). This chapter provides that depth so you can design monitoring that not only observes but reacts.

7.2 Metrics, Namespaces, and the CloudWatch Agent

CloudWatch metrics are organized bynamespace(the service, e.g.AWS/EC2) and identified bydimensions(name/value pairs like InstanceId). A crucial exam point: some metrics aren’t available by default. EC2 publishes CPU, network, and disk (of the hypervisor) automatically, butmemory and disk-space usage inside the instance require the CloudWatch agent- a unified agent that also shipslogsto CloudWatch Logs. You publishcustom metricsvia the API/agent (standard 1-minute orhigh-resolutiondown to 1-second), and the**Embedded Metric Format (EMF)**lets you emit structured logs that CloudWatch automatically extracts as metrics. Knowing that memory needs the agent, and how custom/high-resolution metrics and EMF work, is tested.

7.3 Metric Math, Anomaly Detection, and Composite Alarms

Beyond simple thresholds, CloudWatch offersmetric math(compute new time series from existing metrics - e.g. error rate = errors ÷ requests),anomaly detection(ML learns a metric’s normal band and alarms on deviation, for metrics without a fixed threshold), andcomposite alarms(combine multiple alarms with AND/OR logic to reduce noise - alarm only when several conditions hold). An alarm has three states (OK, ALARM, INSUFFICIENT_DATA) and evaluates a metric over a number of periods/datapoints. These features let you alert on meaningful derived conditions (a computed error rate, an anomalous pattern, a correlation of signals) rather than crude single-metric thresholds, reducing false positives.

flowchart TB
  Metric[Metric or metric-math expression] --> Alarm{Alarm: threshold / anomaly band}
  Alarm -->|ALARM| SNS[SNS notification]
  Alarm -->|ALARM| ASG[Auto Scaling action]
  Alarm -->|ALARM| EC2A[EC2 action: recover/reboot/stop]
  Alarm -->|ALARM| SSM[SSM / Systems Manager automation]
  Comp[Composite alarm - AND/OR of alarms] -.reduce noise.-> SNS

7.4 Alarm Actions: Automating Response

The exam emphasizes what an alarmdoes. Alarm actions include: sending anSNS notification(to email, chat, or a paging system, or to trigger a Lambda subscribed to the topic); triggering anAuto Scalingaction (scale out/in); anEC2 action- notablyrecover(recovers a failed instance onto new hardware keeping its IP/EBS, for underlying-hardware failures), reboot, stop, or terminate; and initiatingSystems Managerautomation or OpsCenter items. This is how monitoring becomes self-healing: a status-check-failed alarm auto-recovers the instance, a high-load alarm scales out, and a custom condition triggers an SSM runbook - without human intervention. Knowing the EC2recoveraction for hardware failure is a classic exam answer.

7.5 Contributor Insights and Cross-Account Observability

Two more capabilities.CloudWatch Contributor Insightsanalyzes log data to show the top contributors to a metric (the “top talkers” - which IPs, keys, or users drive traffic or errors) - useful for finding a hot key or an abusive client.Cross-account observabilitylets a central monitoring account aggregate metrics, logs, and traces from many source accounts, giving a single pane across the organization (essential for multi-account estates). These support the enterprise-scale, multi-account monitoring the professional exam expects.

7.6 Banking Production Scenario

A bank runs the CloudWatch agent on all instances to capture memory and disk metrics and ship logs, and emits custom business metrics (payment success rate) via EMF. Metric math computes error rate, anomaly detection alarms on unusual latency, and composite alarms fire only when error rateandlatency are both abnormal, cutting noise. Alarm actions automate response: a status-check alarm triggers EC2recoverfor hardware failures, a load alarm drives Auto Scaling, and a custom-condition alarm launches an SSM Automation runbook. Contributor Insights surfaces the top clients during a traffic spike. A central monitoring account aggregates observability across all workload accounts via cross-account observability. This monitoring-that-reacts design is exactly the professional-level operational architecture the certification targets.

7.7 Chapter Revision Notes

  • Metrics have namespaces + dimensions; memory/disk-space inside an instance need the CloudWatch agent (which also ships logs); custom metrics can be high-resolution (1s); EMF extracts metrics from structured logs.
  • Metric math (derived series like error rate), anomaly detection (ML band), and composite alarms (AND/OR) enable meaningful, low-noise alerting; alarm states: OK/ALARM/INSUFFICIENT_DATA.
  • Alarm actions: SNS (notify/trigger Lambda), Auto Scaling, EC2 action (recover for hardware failure, reboot/stop/terminate), SSM automation - monitoring becomes self-healing.
  • Contributor Insights finds top contributors (hot keys/clients); cross-account observability centralizes metrics/logs/traces across accounts.
  • EC2 alarm “recover” action moves a failed instance to new hardware keeping IP/EBS - the answer for underlying hardware failure.