DVA-C02 Question 376
Select 3You are developing a serverless application using AWS Lambda and Amazon API Gateway. You want to monitor the performance of your application and need to track both built-in metrics like invocation duration, as well as custom metrics such as the number of specific business transactions processed. Which combination of actions should you take to achieve this?
- A
Enable Amazon CloudWatch Logs for your Lambda function to monitor built-in metrics like invocation duration.
- B
Use the AWS SDK to publish custom metrics to Amazon CloudWatch using the PutMetricData API.
- C
Enable X-Ray tracing for your Lambda function to automatically log custom metrics to Amazon CloudWatch.
- D
Set up a CloudWatch dashboard to visualize both built-in and custom metrics.
- E
Use Amazon S3 events to trigger a Lambda function that logs metrics to CloudWatch.
Show answer and explanation
Correct answers: A, B, D
Explanation
To effectively monitor both built-in and custom metrics for your Lambda application, you should enable Amazon CloudWatch Logs for built-in metrics, use the AWS SDK's PutMetricData API to publish custom metrics, and set up CloudWatch dashboards to visualize all metrics. X-Ray is primarily for tracing, and using S3 events to log metrics is not a standard practice.
- A. Correct.
This is correct because Amazon CloudWatch Logs is where built-in metrics for AWS Lambda functions, such as invocation duration and error counts, are automatically sent.
- B. Correct.
This is correct because the AWS SDK provides the PutMetricData API, which allows you to publish custom application-specific metrics to Amazon CloudWatch.
- C. Incorrect.
This is incorrect because X-Ray is primarily used for distributed tracing and debugging, not for logging custom metrics automatically. You would still need to explicitly publish custom metrics to CloudWatch.
- D. Correct.
This is correct because CloudWatch dashboards allow you to visualize both built-in and custom metrics in a single view for monitoring purposes.
- E. Incorrect.
This is incorrect because while S3 events can trigger Lambda functions, it does not directly relate to logging built-in or custom metrics to CloudWatch.