DVA-C02 Question 378
Select 3You are developing a serverless application using AWS Lambda, and you want to monitor the execution duration and error counts of your functions. Additionally, you need to track a custom metric for the number of specific events processed by the Lambda function. Which approach should you take to achieve this?
- A
Enable AWS Lambda's built-in metrics in Amazon CloudWatch.
- B
Use the AWS SDK to publish a custom metric to Amazon CloudWatch for the specific event count.
- C
Embed logging statements in your Lambda function to monitor execution duration and errors.
- D
Enable X-Ray tracing for the Lambda function to automatically monitor all required metrics.
- E
Use Amazon CloudWatch Embedded Metric Format (EMF) to publish custom metrics directly from the Lambda function.
Show answer and explanation
Correct answers: A, B, E
Explanation
To monitor a Lambda function's execution duration and error counts, you can rely on AWS Lambda's built-in metrics, which are automatically available in Amazon CloudWatch. For custom metrics, such as the number of specific events processed, you can use the AWS SDK to publish custom metrics or leverage the Amazon CloudWatch Embedded Metric Format (EMF) for direct and efficient metric publishing. Logging statements and X-Ray tracing are useful for other purposes but are not the best solutions for the specific requirements in this scenario.
- A. Correct.
Correct. AWS Lambda automatically provides built-in metrics such as execution duration and error counts, which are available in Amazon CloudWatch.
- B. Correct.
Correct. Using the AWS SDK, you can publish custom metrics, such as the number of specific events processed, to Amazon CloudWatch.
- C. Incorrect.
Incorrect. Logging statements are useful for debugging, but they are not a recommended approach to monitor execution duration and errors or to publish custom metrics.
- D. Incorrect.
Incorrect. Enabling X-Ray tracing provides detailed insights into application performance but does not replace the need for CloudWatch metrics, nor does it help with custom metrics.
- E. Correct.
Correct. The Amazon CloudWatch Embedded Metric Format (EMF) allows you to directly publish custom metrics from a Lambda function to CloudWatch in a structured and efficient manner.