CloudWatch metrics
- Namespace → metric name → dimensions (e.g.
AWS/Lambda,Errors,FunctionName=x). - Standard resolution 1 min; high resolution 1 s (custom metrics).
- Statistics: Sum, Average, Min, Max, SampleCount, percentiles (
p99). - Embedded Metric Format (EMF): emit metrics via structured logs, no API calls.
console.log(JSON.stringify({
_aws: { Timestamp: Date.now(), CloudWatchMetrics: [{ Namespace: 'Checkout',
Dimensions: [['Service']], Metrics: [{ Name: 'Latency', Unit: 'Milliseconds' }] }] },
Service: 'api', Latency: 123,
}));Key metrics to know
| Service | Watch |
|---|---|
| Lambda | Errors, Throttles, Duration, ConcurrentExecutions, IteratorAge |
| SQS | ApproximateNumberOfMessagesVisible, ApproximateAgeOfOldestMessage |
| ALB | HTTPCode_Target_5XX_Count, TargetResponseTime, UnHealthyHostCount |
| ECS | CPUUtilization, MemoryUtilization, RunningTaskCount |
| API Gateway | 5XXError, 4XXError, Latency, IntegrationLatency |
| DynamoDB | ThrottledRequests, ConsumedRead/WriteCapacityUnits |
| RDS | CPUUtilization, DatabaseConnections, FreeStorageSpace, ReplicaLag |
Alarms
- States: OK, ALARM, INSUFFICIENT_DATA. Evaluate N of M datapoints.
- Actions: SNS, Auto Scaling, EC2 actions, Systems Manager.
- Composite alarms combine alarms (reduce noise).
- Anomaly detection bands for seasonal metrics.
- Treat missing data explicitly (
notBreachingfor sparse error metrics).
Logs Insights
fields @timestamp, @message, level, traceId
| filter level = "ERROR" and service = "checkout"
| sort @timestamp desc
| limit 50
stats count(*) as errors by bin(5m), service
filter @type = "REPORT"
| stats avg(@duration), pct(@duration, 99), max(@maxMemoryUsed / 1000 / 1000) by bin(1h)
parse @message "user=* action=*" as user, action | stats count() by actionMetric filters turn log patterns into metrics; subscription filters stream logs to Lambda/Firehose/OpenSearch.
X-Ray
- Traces → segments (per service) → subsegments (downstream calls).
- Annotations: indexed, filterable (
annotation.customer = "acme"). Metadata: not indexed. - Service map shows dependencies, latency and error rates per edge.
- Sampling rules: default first request/sec + 5% of additional.
- Enable: Lambda active tracing, API Gateway tracing, ECS sidecar daemon or ADOT collector.
- Filter expressions:
service("checkout") AND responsetime > 2,fault = true.
Other CloudWatch features
- Synthetics canaries for uptime/user flows.
- RUM for browser performance.
- ServiceLens / Application Signals: SLOs and service health from metrics + traces.
- Container Insights and Lambda Insights for deeper runtime metrics.
- Dashboards across accounts/regions; cross-account observability.