A SysOps Administrator is monitoring an application running on a fleet of Amazon EC2 instances. The application logs are streamed to an Amazon CloudWatch Logs log group named `/aws/app/production-backend` using the CloudWatch agent. The logs are structured in JSON format as follows:
{
"request_id": "req-9823f",
"path": "/checkout",
"latency_ms": 350,
"db_queries": 4
}
The administrator needs to monitor occurrences of high latency for the `/checkout` path. Specifically, they must trigger an AWS SNS notification if there are more than requests to `/checkout` where `` exceeds within any -minute window.
Which of the following configurations will meet these requirements?
- ACreate a metric filter with the pattern `[path = "/checkout", latency_ms > 500]` and set the metric value to ` 1$-minute period.
- Create a metric filter with the pattern `{ .path = "/checkout" && .latency_ms > 500 }`, and set the metric value to `1`. Configure a CloudWatch alarm based on this metric using the `Sum` statistic and a period of minute ( seconds).Answer
- CEnable Detailed Monitoring on the EC2 instances to allow CloudWatch to process log-derived metrics at -minute intervals. Then, create a metric filter with the pattern `{ .path = "/checkout" && .latency_ms > 500 }` and a metric value of `1` to feed the alarm.
- DCreate a metric filter with the pattern `{ .path = "/checkout" && .latency_ms > 500 }` and set the metric value to `1`. In the CloudWatch log group properties, change the log retention period to day to ensure that metric data points are processed and aggregated every hours to prevent older logs from affecting the alarm evaluation.
Answer
Create a metric filter with the pattern `{ .path = "/checkout" && .latency_ms > 500 }`, and set the metric value to `1`. Configure a CloudWatch alarm based on this metric using the `Sum` statistic and a period of minute ( seconds).
The correct answer uses the proper JSON filter pattern syntax `{ .path = "/checkout" && .latency_ms > 500 }`. By setting the metric value to `1`, each matching log entry acts as a single count. Applying the `Sum` statistic over minute ( seconds) with a threshold of matches the business requirements. Additionally, because CloudWatch Logs metric filters process logs on ingestion and publish data points at -minute intervals automatically, changing EC2 instance monitoring configurations is unnecessary.
Step-by-Step Solution
Key Concept
CloudWatch Logs Metric Filters process log streams in real-time to generate metrics at 1-minute resolution, using JSON path expressions to match and extract fields from JSON logs.
Estimated Time:3m 0s