DVA-C02 practice question 35 of 35

A company is building a serverless application on AWS. The application uses an AWS Lambda function to process customer orders 24 hours a day, 7 days…

Full set: 598 questions

Domain Development with AWS Services

A company is building a serverless application on AWS. The application uses an AWS Lambda function to process customer orders 24 hours a day, 7 days a week. The Lambda function calls an external vendor's HTTP API to process payments. During load tests, a developer discovers that the external vendor payment processing API occasionally times out and returns errors. The company expects that some payment processing API calls will return errors. The company wants the support team to receive notifications in near real time only when the payment processing external API error rate exceed 5% of the total number of transactions in an hour. Developers need to use an existing Amazon Simple Notification Service (Amazon SNS) topic that is configured to notify the support team. Which solution will meet these requirements?
Answer options
A: Write the results of payment processing API calls to Amazon CloudWatch. Use Amazon CloudWatch Logs Insights to query the CloudWatch logs. Schedule the Lambda function to check the CloudWatch logs and notify the existing SNS topic.
B: Publish custom metrics to CloudWatch that record the failures of the external payment processing API calls. Configure a CloudWatch alarm to notify the existing SNS topic when error rate exceeds the specified rate. Correct answer
C: Publish the results of the external payment processing API calls to a new Amazon SNS topic. Subscribe the support team members to the new SNS topic.
D: Write the results of the external payment processing API calls to Amazon S3. Schedule an Amazon Athena query to run at regular intervals. Configure Athena to send notifications to the existing SNS topic when the error rate exceeds the specified rate.
Correct Answer:
B. Publish custom metrics to CloudWatch that record the failures of the external payment processing API calls. Configure a CloudWatch alarm to notify the existing SNS topic when error rate exceeds the specified rate.
Explanation

The most effective and direct solution is to use Amazon CloudWatch custom metrics and alarms. The Lambda function can be instrumented to publish a custom metric for each successful and failed API call to the external vendor. A CloudWatch alarm can then be configured using Metric Math to calculate the error rate (e.g., (failures / (successes + failures)) 100) over the specified one-hour period. When this calculated rate exceeds the 5% threshold, the alarm will trigger and send a notification to the pre-configured, existing SNS topic. This approach provides near real-time monitoring and alerting, precisely meeting the requirements.

Why Incorrect

A. Scheduling a Lambda function to query CloudWatch Logs is a polling mechanism that introduces unnecessary latency and complexity, failing the "near real-time" requirement compared to a push-based alarm.
C. This would notify the support team for every API call result, not just when the error rate exceeds a specific threshold. This fails to meet the core requirement of conditional alerting.
D. Using Amazon S3 and Athena is designed for batch analytics and interactive querying, not for near real-time monitoring and alerting. This solution would have significant delays and is overly complex.

References

1. Amazon CloudWatch User Guide - Publishing custom metrics: "You can publish your own metrics to CloudWatch using the AWS CLI or an API. ... You can then view statistical graphs of your published metrics with the AWS Management Console." This supports the first part of the correct answer. (See section: "Publish custom metrics").

2. Amazon CloudWatch User Guide - Using Amazon CloudWatch alarms: "You can create an alarm to monitor any Amazon CloudWatch metric in your account. ... If the metric breaches the threshold for the number of evaluation periods you specify, the alarm performs one or more actions that you specify. ... For example, you can configure an alarm to send a notification to an Amazon SNS topic." This confirms the alarm-to-SNS integration. (See section: "Using Amazon CloudWatch alarms").

3. Amazon CloudWatch User Guide - Create a CloudWatch alarm based on a metric math expression: "You can create a CloudWatch alarm that evaluates a metric math expression. ... For example, you can create an alarm that is triggered if the error rate of a fleet of EC2 instances is too high." This directly addresses the requirement to monitor a calculated rate. (See section: "Metric Math alarm examples").

4. AWS Lambda Developer Guide - Instrumenting your code to generate custom metrics: "For business or application-level metrics, you can create custom metrics. For example, you can record the number of records processed or calls to a downstream service." This confirms that instrumenting the Lambda function to create these metrics is a standard practice. (See section: "Working with Lambda function metrics").

Scroll to Top