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?
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.
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.
To create a custom metric for failed profile update attempts due to validation errors, the developer should use the CloudWatch PutMetricData API. This action allows for publishing of custom metrics directly to Amazon CloudWatch. Using the AWS SDK to increment a custom metric ensures that each specific scenario such as 'failed update attempts due to validation errors' is tracked accurately. While creating a new log stream and logging error messages to CloudWatch Logs does provide persistence of error data, it does not fulfill the requirement of creating and utilizing a custom metric. Similarly, using AWS X-Ray to trace requests would provide insights into the request flow and latency but would not create a custom metric. Finally, emitting logs with the embedded metric format (EMF) would be a valid approach for collecting custom metrics from Lambda logs, but since the question specifies using the PutMetricData API, the correct approach is to use the AWS SDK to call PutMetricData.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is Amazon CloudWatch and how does it relate to monitoring metrics?
Open an interactive chat with Bash
What is the AWS SDK and how is it used in Lambda functions?
Open an interactive chat with Bash
Can you explain the CloudWatch PutMetricData API and its use case?
Open an interactive chat with Bash
AWS Certified Developer Associate DVA-C02
Troubleshooting and Optimization
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access