Skip to main content
AWS Observability Stack

Module Overview

Estimated Time: 3-4 hours | Difficulty: Intermediate | Prerequisites: Core Concepts, Compute
Observability is critical for running production workloads. Without it, debugging production issues is like diagnosing a patient over the phone with no test results — you are guessing. Metrics tell you WHAT is happening (fever), logs tell you WHY (infection details), and traces tell you WHERE (which organ). This module covers the complete AWS monitoring stack for logs, metrics, traces, and alerts. What You’ll Learn:
  • CloudWatch metrics, logs, and alarms
  • X-Ray distributed tracing
  • CloudTrail for audit logging
  • EventBridge for event-driven automation
  • Building observability dashboards
  • Alerting and incident response

Observability Pillars


CloudWatch Metrics

Collect and track metrics from AWS services and custom applications.

Built-in vs Custom Metrics

Publishing Custom Metrics

CloudWatch Embedded Metric Format (EMF)


CloudWatch Logs

Centralized log management for all AWS services and applications. CloudWatch Logs is often the single biggest line item on an AWS bill that teams do not expect — a service generating 100 GB of logs per day costs roughly $1,500/month in ingestion alone, before storage and queries.

Log Architecture

Structured Logging Best Practices

CloudWatch Logs Insights


X-Ray Distributed Tracing

Trace requests across microservices to identify bottlenecks and errors. While metrics tell you “p99 latency is 3 seconds” and logs tell you “this function threw an error,” traces tell you “the request spent 2.5 of those 3 seconds waiting on a DynamoDB call that was throttled.” Traces are the only tool that gives you a request-level view across service boundaries.

X-Ray Architecture

Instrumenting Lambda with X-Ray


CloudWatch Alarms

Automated alerts and actions based on metric thresholds.

Alarm Architecture

Essential Alarms (Terraform)


CloudTrail (Audit Logging)

Track all API calls for security and compliance.

CloudTrail Best Practices


🎯 Interview Questions

Systematic approach:
  1. X-Ray Trace: Find the specific slow request
    • Identify which service/subsegment is slow
    • Check annotations for context
  2. CloudWatch Metrics: Check historical patterns
    • Is this a spike or gradual increase?
    • Correlate with CPU, memory, connections
  3. CloudWatch Logs: Find related errors
  4. Service-specific checks:
    • Lambda: Cold starts? Memory sufficient?
    • DynamoDB: Throttling? Hot partition?
    • RDS: Connection pool exhausted?
Essential metrics by layer:Load Balancer:
  • RequestCount, TargetResponseTime
  • HTTPCode_Target_5XX, HTTPCode_ELB_5XX
  • HealthyHostCount, UnhealthyHostCount
Compute (EC2/Lambda):
  • CPUUtilization, MemoryUtilization (custom)
  • Lambda: Duration, Errors, Throttles
Database:
  • CPUUtilization, FreeableMemory
  • DatabaseConnections, ReadIOPS, WriteIOPS
  • DynamoDB: ThrottledRequests
Application:
  • Error rate, Latency (p50, p95, p99)
  • Requests per second
  • Business metrics (orders, signups)
Cost optimization strategies:
  1. Reduce ingestion:
    • Filter logs at source (log level INFO not DEBUG)
    • Use sampling for high-volume logs
  2. Optimize retention:
    • Set appropriate retention (7-30 days for most)
    • Export to S3 for long-term (cheaper)
  3. Use Logs Insights efficiently:
    • Narrow time ranges
    • Use specific log groups
    • Cache common queries
  4. Consider alternatives:
    • Kinesis Firehose → S3 for high volume
    • OpenSearch for complex analysis
Alert hierarchy:
  1. Critical (PagerDuty/immediate):
    • Service down (health check failures)
    • Error rate > 5%
    • Latency p99 > 5s
    • Security events (root login)
  2. Warning (Slack/email):
    • Error rate > 1%
    • CPU > 80% sustained
    • Disk > 85%
    • Approaching quotas
  3. Informational (dashboard):
    • Deployment events
    • Scaling events
    • Cost anomalies
Best practices:
  • Avoid alert fatigue (tune thresholds)
  • Use composite alarms
  • Include runbook links in alerts
CloudWatch advantages:
  • Native integration, no agents for AWS services
  • Lower cost for basic use cases
  • No data egress charges
Third-party advantages (Datadog, New Relic):
  • Better visualization and correlation
  • APM with code-level insights
  • Multi-cloud support
  • More powerful querying
Hybrid approach:
  • Use CloudWatch for AWS metrics/logs
  • Stream to third-party for analysis
  • Keep costs balanced

🧪 Hands-On Lab: Build Observability Dashboard

1

Enable X-Ray on Lambda

Add X-Ray SDK and enable active tracing
2

Create CloudWatch Dashboard

Add widgets for key metrics (CPU, errors, latency)
3

Set Up Structured Logging

Implement JSON logging with correlation IDs
4

Create Alarms

Set up CPU, error rate, and latency alarms
5

Configure CloudTrail

Enable multi-region trail with CloudWatch Logs

Next Module

CDN & Edge Services

Master CloudFront, Global Accelerator, and edge computing