A mobile application sends HTTP requests to an Application Load Balancer (ALB) that routes to an AWS Lambda function. Multiple app versions are in use and the app version is provided in the User-Agent header. The Lambda function has been modified to extract the API operation name, the application version from the User-Agent header, and the response code. What additional steps should the DevOps engineer take to collect metrics for each API operation by response code and by application version?
Choose an answer
Tap an option to check your answer.
Correct answer: Have the Lambda function write log lines containing the API operation name, response code, and application version to an Amazon CloudWatch Logs log group. Create a CloudWatch Logs metric filter that increments a metric for each API operation, and use response code and application version as metric dimensions..
Why this is the answer
The most effective solution is to leverage CloudWatch Logs and metric filters. The Lambda function already extracts the necessary data (API operation, response code, application version). By writing this information as structured log lines to CloudWatch Logs, you create a data source. CloudWatch Logs metric filters can then parse these log lines to extract specific values and publish them as custom metrics. Using response code and application version as dimensions allows for granular analysis and visualization of the metrics, fulfilling all requirements. Incorrect options: CloudWatch Logs Insights queries are for ad-hoc analysis, not for continuously populating CloudWatch metrics. ALB access logs capture request details but the Lambda function is the source of the API operation name, response code, and application version. Modifying ALB response metadata for this purpose is not a standard or efficient way to collect these specific metrics. AWS X-Ray is excellent for tracing and debugging, but its primary purpose is not to generate custom business metrics with specific dimensions like this. While it can provide some insights, CloudWatch Logs with metric filters is the more direct and suitable service for this requirement.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed