Soru

Zorluk: OrtaCloudWatch Logs and Metric Filters

A SysOps Administrator is configuring a monitoring solution for a microservice that publishes system events to an Amazon CloudWatch log group named `/aws/microservices/order-processor`. The application outputs log messages in the following JSON format:

{
"request_id": "req-9481",
"status": "FAILURE",
"error_code": "ERR_PAYMENT_DECLINED",
"processing_time_ms": 1420
}

The administrator needs to monitor for instances where payments are declined and trigger automated notifications. Which two actions must the administrator perform to achieve this requirement?

  1. Create a CloudWatch Logs metric filter with the filter pattern `{ $.error_code = "ERR_PAYMENT_DECLINED" }` that increments a custom metric by 1 when a match is found.Cevap
  2. Create a CloudWatch alarm that monitors the custom metric and is configured to send a notification to an Amazon SNS topic when the metric exceeds the defined threshold.Cevap
  3. C
    Enable detailed monitoring on the microservice host instances to ensure the custom log metric is updated and reported at 1-minute intervals.
  4. D
    Configure an Amazon EventBridge rule with an event pattern matching the `/aws/microservices/order-processor` log group to directly trigger an Amazon SNS notification when a declined payment event is logged.
  5. E
    Configure the retention settings of the metric filter to ensure that logs matching the declined payment pattern are stored indefinitely while other logs are expired.

Cevap

The administrator must create a CloudWatch Logs metric filter with the filter pattern `{ $.error_code = "ERR_PAYMENT_DECLINED" }` to increment a custom metric, and then create a CloudWatch alarm to monitor that custom metric and trigger notifications to an Amazon SNS topic.
To detect specific events in JSON logs and send notifications, a metric filter must be created with the pattern `{ $.error_code = "ERR_PAYMENT_DECLINED" }` to publish data to a custom metric. A CloudWatch alarm is then set up to monitor that custom metric and trigger an action, such as sending a notification to an Amazon SNS topic when the threshold is breached.

Adım Adım Çözüm

1
Define a CloudWatch Logs metric filter on the log group `/aws/microservices/order-processor`.
The metric filter will inspect incoming log events in real-time.
Metric filters scan logs as they are ingested to match specified patterns.
2
Use the filter pattern `{ $.error_code = "ERR_PAYMENT_DECLINED" }` to increment a custom metric.
A custom metric is updated whenever a declined payment is logged.
JSON logs allow querying property values using the `$.property` notation in the filter pattern.
3
Create a CloudWatch alarm linked to the custom metric, configuring its action to notify an Amazon SNS topic.
An alert is dispatched via SNS when the failure rate or count exceeds the specified threshold.
Metric filters do not trigger actions directly; they must publish to a metric, which is then evaluated by an alarm.

Anahtar Kavram

Using CloudWatch Logs metric filters to extract metrics from JSON-formatted log files and triggering alerts using CloudWatch alarms and Amazon SNS.
Tahmini Süre:2m 0s
Bu soruyu puanla