AWS Certified Developer – Associate (DVA-C02) — Question 511
An AWS Lambda function that handles application requests uses the default Lambda logging mechanism to log the timestamp, processing time, and status of requests.
A developer needs to create Amazon CloudWatch metrics based on the logs. The developer needs to write the metrics to a custom CloudWatch metrics namespace.
Which solution will meet these requirements?
Answer options
- A. Use Amazon CloudWatch Logs Insights to generate custom metrics from the logs by using CloudWatch embedded metric format (EMF).
- B. Use Amazon CloudWatch RUM to generate custom metrics from the logs by using CloudWatch embedded metric format (EMF).
- C. Use Amazon CloudWatch Logs Insights to generate custom metrics from the logs by using JSON format.
- D. Use the CloudWatch embedded metric format (EMF) for the structure of the log statements to generate custom CloudWatch metrics.
Correct answer: D
Explanation
Using the CloudWatch embedded metric format (EMF) allows developers to output complex metric data within structured log statements, which CloudWatch Logs automatically parses to create custom metrics in a specified namespace. CloudWatch Logs Insights is a query tool and cannot directly generate or write persistent custom metrics to a namespace in this manner. CloudWatch RUM is designed for real-user monitoring of web applications and is not used for parsing Lambda log outputs into metrics.