DOP-C02 Practice Question 26: Metric Filter Error Alarm
AWS Certified DevOps Engineer – Professional (DOP-C02) · Test 3 · question 6 of 10
An application writes structured JSON log events to a single Amazon CloudWatch Logs log group. The operations team must be paged within five minutes whenever more than 10 events with "level": "ERROR" and "service": "payments" are written in a five-minute period. They also want to chart the count of those events on a dashboard for the past 12 months, while the log group's retention is set to 30 days. The solution must add as little recurring cost and maintenance as possible.
Which solution meets these requirements?
Show answer and explanation
Answer:
Metric filters exist for exactly this: "CloudWatch Logs uses these metric filters to turn log data into numerical CloudWatch metrics that you can graph or set an alarm on." A JSON filter pattern can match on both fields at once, the metric value is 1 per matching event, and setting a default value of 0 keeps the metric from going sparse. Because the result is an ordinary CloudWatch metric, the alarm evaluates it in near real time and the data points remain available for 15 months, longer than the 12-month dashboard window, even though the raw logs are aged out after 30 days. There is no per-query charge and nothing to maintain.
Option A works but pays twice over: Logs Insights is billed on the volume of log data scanned by each query, and a query every five minutes forever is a recurring cost plus a Lambda function to own. It also cannot chart anything older than the log group's 30-day retention.
Option B is a batch pipeline. Delivery to Firehose and S3 plus a scheduled Athena query adds minutes of latency and several billable services, and the team still has to build the alarm logic that CloudWatch would give them for free.
Option D describes a capability that does not exist. Logs Insights is an interactive query interface; you cannot attach a CloudWatch alarm to a saved query. Turning a log pattern into an alarmable metric is what a metric filter is for.