Which additional set of actions should the DevOps engineer take to gather the required metrics?
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. Configure a CloudWatch Logs metric filter that increments a metric for each API operation name. Specify response code and application version as dimensions for the metric.
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. Configure a CloudWatch Logs Insights query to populate CloudWatch metrics from the log lines. Specify response code and application version as dimensions for the metric.
Configure the ALB access logs to write to an Amazon CloudWatch Logs log group. Modify the Lambda function to respond to the ALB with the API operation name, response code, and version number as response metadata. Configure a CloudWatch Logs metric filter that increments a metric for each API operation name. Specify response code and application version as dimensions for the metric.
Configure AWS X-Ray integration on the Lambda function. Modify the Lambda function to create an X-Ray subsegment with the API operation name, response code, and version number. Configure X-Ray insights to extract an aggregated metric for each API operation name and to publish the metric to Amazon CloudWatch. Specify response code and application version as dimensions for the metric.
Explanations:
This option effectively captures the API operation name, response code, and version number in the Lambda function logs. By using a CloudWatch Logs metric filter, it can increment metrics based on these log lines, with response code and application version as dimensions. This provides a clear way to track metrics per API operation and version.
While this option does involve logging the required data and querying it through CloudWatch Logs Insights, it does not directly create metrics that can be monitored over time. Instead, it relies on querying logs, which is less efficient for real-time metric tracking and aggregation. Metrics should ideally be published directly to CloudWatch for better performance.
This option suggests using ALB access logs, which primarily focus on traffic management rather than detailed API call metrics. Modifying the Lambda response does not facilitate capturing metrics since it doesn’t log the relevant API operation directly. Additionally, ALB logs may not include application version details unless explicitly defined in the log configuration.
Although AWS X-Ray can provide tracing capabilities and insights, the proposed method of creating subsegments and extracting metrics requires additional setup and may not directly translate into metrics based on the response code and application version for each API operation. This approach is more complex and may not meet the immediate requirement of gathering metrics without additional configuration.