Question

Difficulty: Very hardCloudWatch Logs and Metric Filters

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 55 requests to `/checkout` where `latencymslatency_ms` exceeds 500500 within any 11-minute window.

Which of the following configurations will meet these requirements?

  1. A
    Create a metric filter with the pattern `[path = "/checkout", latency_ms > 500]` and set the metric value to `.latencyms.CreateanAmazonEventBridgeruletomonitortheloggroupforthispattern,andtriggeranAWSSystemsManagerAutomationdocumenttocountandaggregatetheseoccurrencesovera.latency_ms`. Create an Amazon EventBridge rule to monitor the log group for this pattern, and trigger an AWS Systems Manager Automation document to count and aggregate these occurrences over a 1$-minute period.
  2. 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 11 minute (6060 seconds).Answer
  3. C
    Enable Detailed Monitoring on the EC2 instances to allow CloudWatch to process log-derived metrics at 11-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.
  4. D
    Create 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 11 day to ensure that metric data points are processed and aggregated every 2424 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 11 minute (6060 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 11 minute (6060 seconds) with a threshold of >5> 5 matches the business requirements. Additionally, because CloudWatch Logs metric filters process logs on ingestion and publish data points at 11-minute intervals automatically, changing EC2 instance monitoring configurations is unnecessary.

Step-by-Step Solution

1
Select the correct JSON filter pattern syntax.
`{ .path = "/checkout" && .latency_ms > 500 }`
Since the logs are in JSON format, JSON path matching syntax must be used instead of space-delimited syntax.
2
Define the metric value to represent occurrences rather than values.
Metric Value = `1`
Setting the metric value to `1` ensures that each matching log entry increments the custom metric by 1, which represents an occurrence.
3
Configure the CloudWatch alarm threshold and statistic.
`Sum` statistic over 11 minute (6060 seconds) with threshold >5> 5.
To detect if there are more than 55 occurrences within any 1-minute window, the `Sum` statistic must be aggregated over a 1-minute period.
4
Evaluate the need for EC2 Detailed Monitoring.
No configuration change needed on EC2 instances.
CloudWatch Logs metric filters process logs in real-time as they are sent to CloudWatch Logs, and publish metrics at 11-minute resolution by default.

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
Rate this question