Skip to main content
In this lesson you’ll learn how Amazon CloudWatch provides monitoring, logging, and observability for AWS resources and your applications. CloudWatch collects metrics and logs, lets you query and analyze that data, and can trigger notifications or automated responses when defined thresholds are crossed — making it a central service for operational visibility and automated actions.

What CloudWatch does

CloudWatch centralizes telemetry from AWS services and custom applications. After data is ingested, CloudWatch can:
  • Store and visualize metrics on dashboards.
  • Evaluate metrics against user-defined thresholds and raise alarms.
  • Extract additional metrics from log data (metric filters).
  • Provide ad-hoc log queries and analytics with CloudWatch Logs Insights.
  • Trigger notifications and automated workflows when alarms change state.
  • Route and react to events using rules and targets (see EventBridge).

How CloudWatch collects data

  • Many AWS services (for example Amazon EC2, AWS RDS, AWS Lambda, and Amazon ECS) automatically emit metrics and, in many cases, logs to CloudWatch.
  • Applications and agents can send logs to CloudWatch Logs using the CloudWatch Logs API (PutLogEvents) or the CloudWatch Agent (for EC2 and on-prem servers).
  • Developers can push custom metrics with the CloudWatch SDKs or the PutMetricData API and organize metrics into namespaces to represent application-specific data such as latency or business KPIs.
Example: sending a custom metric via AWS CLI
Example: sending logs using the CloudWatch Logs API (JSON payload excerpt)

What you can do with ingested logs and metrics

  • Create alarms that evaluate metrics over one or more evaluation periods and trigger actions.
  • Define metric filters to extract numerical metrics from log entries (e.g., count of ERROR messages).
  • Query logs with Logs Insights to troubleshoot issues and create visualizations for dashboards.
  • Route events and react to resource state changes using rules and supported targets (Lambda, SNS, SQS, Step Functions, API destinations).

Key CloudWatch components

A diagram titled "CloudWatch Components" showing four columns: Metrics, Alarms, Logs, and Events. Each column lists subcomponents (e.g., Namespaces, Dimensions, Resolutions; Actions, Thresholds; Log Streams, Log Groups; Rules, Targets).

CloudWatch and Auto Scaling

CloudWatch metrics and alarms are commonly used to automate scaling decisions for Auto Scaling groups. A typical workflow:
  1. Create a metric (or use a built-in metric) such as average CPUUtilization across EC2 instances.
  2. Define an alarm that evaluates the metric (for example, CPU > 80% for 5 minutes).
  3. Configure the alarm to trigger Auto Scaling policies when the alarm enters the ALARM state (scale out).
  4. Configure recovery/scale-in policies for when the alarm returns to OK.
This enables automated horizontal scaling based on real-time telemetry.

Practical notes and typical workflows

  • Publish application metrics with PutMetricData or SDKs to monitor application-specific KPIs.
  • Use the CloudWatch Agent on EC2 or on-prem hosts to collect system and application logs and metrics.
  • Create metric filters on log groups to emit CloudWatch metrics for specific log patterns (e.g., error counts).
  • Connect CloudWatch Alarms to SNS for notifications or to Lambda/Auto Scaling for automated remediation.
  • Use Logs Insights to run queries, create saved queries, and add visualizations to dashboards for ongoing troubleshooting.
Note: CloudWatch Events has been succeeded by Amazon EventBridge. EventBridge extends the original CloudWatch Events functionality with more features and integrations, but the event-driven workflow and the concepts of rules and targets remain the same.

Summary

  • Amazon CloudWatch ingests metrics and logs from AWS services and custom applications, enabling centralized monitoring and observability.
  • CloudWatch evaluates metrics with alarms, visualizes data on dashboards, and triggers notifications or automated actions.
  • CloudWatch Logs provides retention, indexing, metric filters, and Logs Insights for deep log analytics.
  • Event-driven automation is provided through EventBridge (formerly CloudWatch Events), which routes events to targets.
  • Use dashboards and Insights to observe, troubleshoot, and optimize application and infrastructure performance.

Watch Video