A company has a mobile application that makes HTTP API calls to an Application Load Balancer (ALB). The ALB routes requests to an AWS Lambda function. Many different versions of the application are in use at any given time, including versions that are in testing by a subset of users. The version of the application is de ned in the user-agent header that is sent with all requests to the API. After a series of recent changes to the API, the company has observed issues with the application. The company needs to gather a metric for each API operation by response code for each version of the application that is in use. A DevOps engineer has modi ed the Lambda function to extract the API operation name, version information from the user-agent header and response code. Which additional set of actions should the DevOps engineer take to gather the required metrics?
Show Answer & Explanation
Correct Answer: A. Modify the Lambda function to write the API operation name, response code, and version number as a log line to an Amazon CloudWatch Logs log group. Con gure a CloudWatch Logs metric lter that increments a metric for each API operation name. Specify response code and application version as dimensions for the metric.
Why A is correct: CloudWatch Logs metric filters are the appropriate solution for extracting custom metrics from log data. When the Lambda function writes structured log lines containing the API operation name, response code, and version number, a metric filter can parse these logs and increment CloudWatch metrics. The dimensions (response code and application version) allow for granular tracking of each combination, which is exactly what's needed to monitor different app versions and their response codes per operation.Why other options are wrong: B: CloudWatch Logs Insights is a query tool for ad-hoc analysis, not for automatically populating metrics. It cannot create real-time metrics with dimensions. C: ALB access logs don't capture custom application data like API operation names or user-agent header details that the Lambda function extracts. Response metadata from Lambda isn't logged in ALB access logs. D: X-Ray is designed for distributed tracing and request analysis, not for creating custom CloudWatch metrics with specific dimensions. While X-Ray can track subsegments, it doesn't natively publish custom metrics to CloudWatch in the way described.