All exams← All AWS Developer Associate (DVA-C02) notes

Monitoring & troubleshooting (CloudWatch, X-Ray): AWS Developer Associate (DVA-C02) revision notes

Revision notes

CloudWatch: metrics, alarms and logs

CloudWatch is the default monitoring backbone for AWS. Every service pushes metrics automatically at 5-minute intervals (standard resolution). Enable Detailed Monitoring on EC2 to get 1-minute granularity - this costs extra and is NOT on by default.

Custom metrics are published with PutMetricData. You can go below 1 minute using High-Resolution metrics (down to 1 second), but this needs the StorageResolution parameter set to 1.

Metric retention matters for the exam

  • Data at 1-second resolution is kept for 3 hours
  • 1-minute data points are kept for 15 days
  • 5-minute data points are kept for 63 days
  • 1-hour data points are kept for 15 months

CloudWatch automatically 'rolls up' older data to coarser resolution - it does not delete it early.

Alarms

An alarm watches a single metric (or a metric math expression) over a number of evaluation periods and moves between OK, ALARM and INSUFFICIENT_DATA states. Composite alarms combine multiple alarms with AND/OR logic. Alarms can trigger SNS notifications, Auto Scaling actions, or EC2 actions (stop, terminate, reboot, recover).

Logs

CloudWatch Logs organises data into Log Groups then Log Streams. Set retention per log group (default is Never Expire, which quietly costs money forever - a classic gotcha). Use Metric Filters to turn log patterns (like ERROR strings) into numeric CloudWatch metrics you can alarm on. Subscription Filters stream logs in near real time to Lambda, Kinesis or OpenSearch for further processing. CloudWatch Logs Insights lets you query log data with its own query language without building a pipeline first.

CloudWatch Events / EventBridge

EventBridge (the evolution of CloudWatch Events) reacts to AWS service state changes or scheduled rules (cron/rate expressions) and routes them to targets like Lambda or SNS.

X-Ray for distributed tracing

X-Ray traces a request as it moves through microservices, showing a service map and latency breakdown per hop (called segments and subsegments). You must install the X-Ray daemon (or use the built-in agent on Lambda) and instrument your code with the X-Ray SDK. Annotations are indexed key-value pairs you can filter traces by; metadata is not indexed and is for extra context only. Sampling defaults to recording the first request each second plus 5% of additional requests - tune this with sampling rules to control cost.

Common exam traps

  • Detailed Monitoring (1-min) is opt-in and chargeable, not default
  • Metric filters count matching log LINES, they don't parse arbitrary JSON structure without a defined pattern
  • X-Ray needs IAM permissions (xray:PutTraceSegments) even inside Lambda
  • Annotations are searchable, metadata is not - mixing these up is a favourite distractor

Key facts

Flashcards

What is the default CloudWatch metric resolution for most AWS services?
5 minutes (standard resolution); Detailed Monitoring gives 1-minute but must be enabled and costs extra
tap to reveal
How do you publish a custom metric at sub-minute resolution?
Call PutMetricData with StorageResolution set to 1, giving 1-second high-resolution metrics
tap to reveal
How long is 1-minute resolution CloudWatch metric data retained?
15 days
tap to reveal
How long is 5-minute resolution CloudWatch metric data retained?
63 days
tap to reveal
How long is 1-hour resolution CloudWatch metric data retained?
15 months
tap to reveal
What is the default log group retention period in CloudWatch Logs?
Never Expire - you must set a retention policy explicitly or logs (and cost) accumulate forever
tap to reveal
What turns a CloudWatch Logs pattern into an alarmable numeric metric?
A Metric Filter
tap to reveal
What streams CloudWatch Logs data to Lambda, Kinesis or OpenSearch in near real time?
A Subscription Filter
tap to reveal
What combines multiple CloudWatch alarms with AND/OR logic?
A Composite Alarm
tap to reveal
What are the three states a CloudWatch alarm can be in?
OK, ALARM, and INSUFFICIENT_DATA
tap to reveal
What component collects trace data on an EC2 instance for X-Ray?
The X-Ray daemon (on Lambda, tracing is built in without needing a separate daemon)
tap to reveal
What is X-Ray's default sampling behaviour?
Records the first request each second plus 5% of any additional requests, and this is configurable via sampling rules
tap to reveal
What is the difference between X-Ray Annotations and Metadata?
Annotations are indexed key-value pairs you can search/filter traces by; Metadata is not indexed and is for extra context only
tap to reveal
What IAM permission does X-Ray tracing require to send trace data?
xray:PutTraceSegments
tap to reveal
What service replaced and expanded CloudWatch Events for event-driven routing?
Amazon EventBridge, which routes AWS state changes or scheduled cron/rate rules to targets like Lambda or SNS
tap to reveal
Practice questions

Monitoring & troubleshooting (CloudWatch, X-Ray): 5 practice questions

Q1. A developer wants a CloudWatch alarm to trigger only after a metric has breached a threshold for 3 consecutive evaluation periods, to avoid reacting to a single transient spike. Which alarm configuration setting controls this?
  • A.  Period set to 3 minutes
  • B.  Statistic set to Sum instead of Average
  • C.  Treat Missing Data set to breaching
  • D.  Datapoints to Alarm set to 3 out of 3
Show answer & explanation
✓ Answer: D. Datapoints to Alarm set to 3 out of 3
'Datapoints to Alarm' lets you specify M out of N evaluation periods that must breach before the alarm fires, which smooths out transient spikes. Changing the statistic or period changes how data is aggregated but not how many breaching periods are required. 'Treat Missing Data' only controls behaviour when data points are absent.
Q2. An application publishes a custom CloudWatch metric called OrderLatency with a resolution of 1 second (high-resolution metric). What is the minimum period a CloudWatch alarm can use to evaluate this metric?
  • A.  10 seconds
  • B.  60 seconds
  • C.  1 second
  • D.  5 minutes
Show answer & explanation
✓ Answer: A. 10 seconds
High-resolution custom metrics support periods of 1, 5, 10, or 30 seconds, or any multiple of 60. Since an alarm period must be at least 10 seconds for high-resolution metrics (1 second is only valid for the PutMetricData call, not alarm periods), 10 seconds is the minimum valid alarm period. Standard-resolution metrics only support 60-second or larger periods.
Q3. A Lambda function occasionally times out, and the developer wants to trace the exact downstream call (DynamoDB, S3, or an external HTTP API) that is causing the delay. Which AWS service is purpose-built for this kind of distributed latency analysis?
  • A.  AWS Config
  • B.  AWS X-Ray
  • C.  Amazon CloudWatch Logs Insights
  • D.  Amazon CloudTrail
Show answer & explanation
✓ Answer: B. AWS X-Ray
AWS X-Ray traces requests as they travel through distributed components, producing a service map and segment/subsegment timing that pinpoints which downstream call added the latency. CloudWatch Logs Insights can query log text but doesn't model call timing across services. CloudTrail records API management-plane calls, not application request traces, and Config tracks resource configuration compliance.
Q4. To enable AWS X-Ray tracing for a Lambda function, which two things does a developer need to do at minimum?
  • A.  Enable detailed monitoring on the function and create a custom metric filter
  • B.  Install the CloudWatch agent on the function and enable VPC Flow Logs
  • C.  Create an X-Ray group and attach it to the function's execution role only
  • D.  Enable Active Tracing on the function and attach a policy allowing xray:PutTraceSegments and xray:PutTelemetryRecords
Show answer & explanation
✓ Answer: D. Enable Active Tracing on the function and attach a policy allowing xray:PutTraceSegments and xray:PutTelemetryRecords
Lambda X-Ray tracing requires turning on Active Tracing (via console, CLI, or the TracingConfig property) and granting the execution role permission to send trace data, typically via the AWSXRayDaemonWriteAccess managed policy covering PutTraceSegments and PutTelemetryRecords. The CloudWatch agent and VPC Flow Logs are unrelated to X-Ray. X-Ray groups organize existing trace data but don't enable tracing themselves.
Q5. A developer instruments an application using the AWS X-Ray SDK and wants to record how long a specific block of code inside a Lambda handler takes, separate from the overall segment. What should they create?
  • A.  A separate CloudWatch alarm for that block of code
  • B.  A new trace ID for that block of code
  • C.  A new sampling rule for that block of code
  • D.  A subsegment around that block of code
Show answer & explanation
✓ Answer: D. A subsegment around that block of code
Subsegments provide granular timing data for specific blocks of code or downstream calls within a segment, and appear nested under the parent segment in the trace timeline. Creating a new trace ID would split the request into an unrelated trace. Sampling rules control which requests are traced overall, not internal timing, and alarms operate on metrics, not code execution timing.
Test yourself
See the AWS Developer Associate (DVA-C02) page

More AWS Developer Associate (DVA-C02) topics