AWS Certified Developer – Associate — Question 186

A company has an AWS Lambda function that runs hourly, reads log files that are stored in Amazon S3, and forwards alerts to Amazon Simple Notification Service (Amazon SNS) topics based on content. A developer wants to add a custom metric to the Lambda function to track the number of alerts of each type for each run. The developer needs to log this information in Amazon CloudWatch in a metric that is named Lambda/AlertCounts.

How should the developer modify the Lambda function to meet this requirement with the LEAST operational overhead?

Answer options

Correct answer: B

Explanation

The correct answer is B because the PutMetricData API operation is specifically designed for publishing custom metrics to CloudWatch, allowing the developer to log the number of alerts efficiently. Option A merely prints information without logging it as a metric, while Options C and D involve operations that do not directly pertain to logging metrics for CloudWatch.