Skip to main content
CloudWatch Deep Dive

Module Overview

Estimated Time: 4-5 hours | Difficulty: Intermediate | Prerequisites: Core Concepts
Amazon CloudWatch is the unified monitoring and observability service for AWS. Think of it as the nervous system of your cloud infrastructure — it collects signals (metrics), records conversations (logs), and triggers reflexes (alarms and auto-scaling actions) when something goes wrong. If you only learn one AWS observability service, make it CloudWatch — every other monitoring tool either feeds into it or reads from it. This module provides a comprehensive deep-dive into CloudWatch capabilities for production monitoring. What You’ll Learn:
  • CloudWatch Metrics (built-in and custom)
  • CloudWatch Logs and Log Insights
  • CloudWatch Alarms and composite alarms
  • Dashboards and visualization
  • CloudWatch Synthetics (canaries)
  • CloudWatch Contributor Insights
  • CloudWatch Anomaly Detection
  • Cross-account and cross-region monitoring

CloudWatch Architecture


CloudWatch Metrics

Built-in Metrics

Metric Dimensions

Custom Metrics

CloudWatch Agent


CloudWatch Logs

Log Architecture

Structured Logging Best Practices

Log Insights Queries

Metric Filters


CloudWatch Alarms

Alarm Types and States

Essential Alarms (Terraform)


CloudWatch Dashboards

Dashboard as Code


CloudWatch Synthetics

Canary tests that monitor your endpoints 24/7.

CloudWatch Contributor Insights

Identify top contributors to high cardinality data.

Best Practices

Set Retention Policies

Configure log retention to balance cost and compliance needs

Use Structured Logging

JSON format enables powerful Log Insights queries

Alert on Symptoms

Focus on user-facing metrics, not just infrastructure

Tune Alarm Thresholds

Avoid alert fatigue with well-calibrated thresholds

Dashboard Hierarchy

Executive → Service → Debug dashboards

Cost Awareness

Monitor CloudWatch costs—they can surprise you

Cost Optimization


🎯 Interview Questions

CloudWatch Logs:
  • Application and system logs
  • What your code outputs
  • Debugging, troubleshooting
X-Ray:
  • Distributed tracing
  • Request flow across services
  • Performance analysis
CloudTrail:
  • AWS API call history
  • Who did what, when
  • Security auditing
  1. Set retention policies (don’t keep forever)
  2. Export to S3 for long-term (use lifecycle rules)
  3. Filter at source (log levels, sampling)
  4. Use metric filters instead of Log Insights for common queries
  5. Compress logs before ingestion
  6. Use Contributor Insights rules for ongoing analysis
Metric Alarms:
  • Monitor single metric
  • Simple threshold or anomaly detection
  • One condition
Composite Alarms:
  • Combine multiple alarms with AND/OR/NOT
  • Reduce alert noise
  • Complex conditions like: “High CPU AND High Memory”
  • Better for on-call (fewer, more actionable alerts)
Why: EC2 basic monitoring doesn’t include memory—it’s inside the OS, not visible to hypervisor.Solution: Install CloudWatch Agent
Built-in: Lambda doesn’t have a direct cold start metric.Solutions:
  1. Init Duration in REPORT logs
  1. Custom metric from code (measure init time)
  2. X-Ray shows initialization segment
  3. Lambda Insights (enhanced monitoring)

🧪 Hands-On Lab

1

Set Up Structured Logging

Implement JSON logging in a Lambda function
2

Create Metric Filter

Extract error count metric from logs
3

Build Dashboard

Create operational dashboard with key metrics
4

Configure Alarms

Set up metric and composite alarms with SNS notification
5

Create Canary

Set up synthetic monitoring for your API endpoint

Next Module

AWS X-Ray

Master distributed tracing with AWS X-Ray