A SysOps Administrator is monitoring a web application hosted on Amazon EC2 instances. The application writes structured JSON logs to an Amazon CloudWatch Logs log group. A representative log event is shown below:
{
"environment": "production",
"http_details": {
"status_code": 502,
"duration_ms": 420
}
}
The Administrator needs to create a custom metric named `BackendLatency` in the `App/Monitoring` namespace. This metric must record the `duration_ms` value only for production environment requests that result in an HTTP 5xx server error (status code to ). Additionally, if the latency exceeds ms, the Administrator wants to trigger an automated workflow to restart the application service on the EC2 instances. Which configuration should the Administrator implement to meet these requirements?
- Create a CloudWatch Logs metric filter with the filter pattern `{ (.environment = "production") && (.http_details.status_code >= 500) && (.http_details.status_code < 600) }` and set the metric value to `.http_details.duration_ms`. Create a CloudWatch alarm based on this metric, and configure an Amazon EventBridge rule that reacts to the alarm state change to trigger an AWS Systems Manager Automation document.Answer
- BCreate a CloudWatch Logs metric filter with the filter pattern `{ (.environment = "production") && (.http_details.status_code = 5*) }` and set the metric value to `$.http_details.duration_ms`. Configure the metric filter's metric transformation properties to directly execute an AWS Systems Manager Automation document when a matching log event is detected.
- CEnable detailed monitoring on the EC2 instances to allow CloudWatch Logs to process custom metrics at 1-minute granularity. Create a metric filter with the filter pattern `{ (.environment = "production") && (.http_details.status_code = 5??) }` and set the metric value to `$.http_details.duration_ms`. Configure a CloudWatch alarm to trigger an Auto Scaling policy to replace the instances.
- DCreate a CloudWatch Logs metric filter with the filter pattern `{ (.environment = "production") && (.http_details.status_code >= 500) && (.http_details.status_code < 600) }` and set the metric value to `.http_details.duration_ms`. Set the log group retention period to 14 days within the metric filter configuration to control storage costs, and configure a custom AWS Config rule to monitor the metric's alarm state and trigger the service restart.