An organization's legacy web application streams its access logs to an Amazon CloudWatch Logs group named `/apps/web-server/access_log` in the following Common Log Format (CLF):
192.0.2.10 - - [14/Jul/2026:10:15:30 +0000] "POST /api/v1/payment HTTP/1.1" 401 1024
A SysOps Administrator needs to create a custom metric to count HTTP unauthorized access attempts to the `/api/v1/payment` endpoint. If the rate of these attempts exceeds per minute, an automated remediation workflow must be triggered. Which configuration and architecture should the SysOps Administrator implement to meet these requirements?
- Create a metric filter on the log group with the pattern `[ip, identity, user, timestamp, request = "*payment*", status_code = 401, size]` to publish a custom metric, and configure a CloudWatch alarm on this metric to trigger an Amazon EventBridge rule.Answer
- BEnable CloudWatch Detailed Monitoring on the underlying web servers to decrease log processing latency to -minute, and configure a metric filter using the JSON pattern `{ .request = "*payment*" && .status_code = 401 }`.
- CConfigure a metric filter using the pattern `[ip, identity, user, timestamp, request = "%payment%", status_code = 401, size]`, and set the log group retention period to at least days to preserve the metric data.
- DCreate an Amazon EventBridge rule with an event pattern matching the log group directly using `[ip, identity, user, timestamp, request = "*payment*", status_code = 401, size]` to route matching logs directly to an AWS Systems Manager Automation document.
Answer
Create a metric filter on the log group with the pattern `[ip, identity, user, timestamp, request = "*payment*", status_code = 401, size]` to publish a custom metric, and configure a CloudWatch alarm on this metric to trigger an Amazon EventBridge rule.
The correct option correctly uses the space-delimited array syntax to define the fields in the Common Log Format (CLF). It filters the fifth field (request) using wildcard asterisks to match requests containing the word 'payment', and filters the sixth field (status_code) to match HTTP 401. It then publishes this count as a custom metric, which is monitored by a CloudWatch alarm that triggers an EventBridge rule for remediation.
Step-by-Step Solution
Key Concept
CloudWatch Logs Metric Filters allow you to parse space-delimited or JSON log entries to publish custom metrics, which can then trigger alarms and automated remediation via EventBridge.
Estimated Time:1m 30s