A SysOps Administrator is setting up an Amazon CloudWatch metric filter to parse JSON logs from an application. The logs contain the following structure:
{ "request_id": "req-102", "service": "billing", "response_time_ms": 350, "status": "FAIL" }
The administrator wants to create a custom metric to track the number of failed billing requests that exceed a response time of ms. The administrator needs to record these occurrences at a -minute resolution in CloudWatch. Which configuration should the administrator use?
- ADefine a metric filter with the pattern `{ .service = "billing" && .status = "FAIL" && .response_time_ms > 300 }` with a metric value of ` 1 1$-minute resolution.
- BDefine a metric filter with the pattern `{ .service = "billing" && .status = "FAIL" && .response_time_ms > 300 }` with a metric value of ` 1 1$ day to enforce the metric reporting interval.
- Define a metric filter with the pattern `{ .service = "billing" && .status = "FAIL" && .response_time_ms > 300 }` and a metric value of ` 1 1$-minute resolution as matching events occur.Answer
- DDefine a metric filter with the pattern `{ .service = "billing" && .status = "FAIL" && .response_time_ms > 300 }` and set the filter destination directly to an AWS Systems Manager Automation document to run at a 1$-minute interval.
Answer
Define a metric filter with the pattern `{ .service = "billing" && .status = "FAIL" && .response_time_ms > 300 }` and a metric value of ` 1 1$-minute resolution as matching events occur.
The correct configuration uses the JSON query syntax `{ .service = "billing" && .status = "FAIL" && .response_time_ms > 300 }` to select the target logs, incrementing the custom metric by ` 1 1$-minute resolution without requiring additional setups.
Step-by-Step Solution
Key Concept
CloudWatch Logs Metric Filters for structured JSON logs