AWS Certified Developer Associate DVA-C02 Practice Question
A developer has written a Lambda function to process incoming user profile updates and wants to track the number of failed update attempts due to validation errors. They need to create a custom metric for this purpose and report it using Amazon CloudWatch. Which approach should the developer use to implement this requirement?
Create a new CloudWatch Logs log stream and write an error message with a specific format for every failed validation attempt.
Implement AWS X-Ray tracing in the Lambda function and filter the trace data to count the validation errors.
Emit logs in the CloudWatch embedded metric format (EMF) from the Lambda function for every failed validation attempt.
Use the AWS SDK in the Lambda function to put a custom metric by calling the CloudWatch PutMetricData API when a validation error occurs.