A developer is monitoring a web application that writes log events to an Amazon CloudWatch Logs log group in the following JSON format:
{
"requestPath": "/payment/process",
"responseCode": 502,
"responseTimeMs": 1500
}
The developer needs to configure a CloudWatch metric filter to count the occurrences of failed payment requests where the `responseCode` is and the `responseTimeMs` is greater than milliseconds.
Which of the following configurations are valid for this metric filter or represent correct troubleshooting actions to ensure the filter works as intended? (Select TWO.)
- Define the metric filter pattern as `{ .responseCode = 502 && .responseTimeMs > 1000 }` to match the JSON properties.Cevap
- BDefine the metric filter pattern as `{ .responseCode == 502 && .responseTimeMs > 1000 }` to compare the properties.
- CDefine the metric filter pattern as `[responseCode = 502, responseTimeMs > 1000]` to filter the log events.
- Ensure that all application logs are written as valid JSON objects, as the JSON filter pattern will ignore malformed JSON or plain text.Cevap
- EIncrease the execution timeout of the AWS Lambda function parsing the logs to prevent the metric filter from timing out.
Cevap
The correct configurations are defining the metric filter pattern as `{ .responseCode = 502 && .responseTimeMs > 1000 }` and ensuring that all application logs are written as valid JSON objects.
The correct choices are using the single equals operator (`=`) inside curly braces to query JSON properties, and ensuring the log events are valid JSON. CloudWatch JSON metric filter syntax requires a single equals sign for comparison and will completely ignore log events that do not conform to valid JSON formatting.
Adım Adım Çözüm
Anahtar Kavram
JSON Metric Filter Syntax and Validation in CloudWatch Logs
Tahmini Süre:2m 0s