AWS Certified DevOps Engineer – Professional (DOP-C02) — Question 341
A company has an application that uploads access logs to an Amazon CloudWatch Logs log group. The fields in the log lines include the response code and the application name.
The company wants to create a CloudWatch metric to track the number of requests by response code in a specific range and with a specific application name.
Which solution will meet these requirements?
Answer options
- A. Create a CloudWatch Logs log event filter on the CloudWatch Logs log stream to match the response code range. Configure the log event filter to increment a metric. Set the response code and application name as dimensions.
- B. Create a CloudWatch Logs metric filter on the CloudWatch Logs log group to match the response code range. Configure the metric filter to increment a metric. Set the response code and application name as dimensions.
- C. Create a CloudWatch Contributor Insights rule on the CloudWatch Logs log stream with a filter to match the response code range. Configure the Contributor Insights rule to increment a CloudWatch metric with the response code and application name as dimensions.
- D. Create a CloudWatch Logs Insights query on the CloudWatch Logs log group to match the response code range. Configure the Logs Insights query to increment a CloudWatch metric with the response code and application name as dimensions.
Correct answer: B
Explanation
CloudWatch Logs metric filters are applied at the log group level, allowing you to scan log events for specific patterns and publish custom metrics with dimensions. Option A is incorrect because metric filters cannot be configured directly on individual log streams. Options C and D are incorrect because neither Contributor Insights nor Logs Insights queries are used to automatically increment and output standard CloudWatch metrics with custom dimensions from incoming logs.