Create a custom metric for blocked requests from a metrics filter and alarm using CloudWatch anomaly detection

Answer Correct answer: A — create a custom blocked-request metric and alarm on it using CloudWatch anomaly detection.

A company runs a web application on Amazon Elastic Kubernetes Service (Amazon EKS). The company uses Amazon CloudFront to distribute the application. The company recently enabled AWS WAF. The company set up Amazon CloudWatch Logs to send logs to an aws-waf-logs log group. The company wants a DevOps engineer to receive alerts if there are sudden changes in blocked traffic. The company does not want to receive alerts for other changes in AWS WAF log behavior. The company will tune AWS WAF rules over time. The DevOps engineer is currently subscribed to an Amazon Simple Notification Service (Amazon SNS) topic in the environment. Which solution will meet these requirements?

  1. Create a CloudWatch Logs metrics filter for blocked requests on the AWS WAF log group to create a custom metric. Create a CloudWatch alarm by using CloudWatch anomaly detection and the published custom metric. Configure the alarm to notify the SNS topic to alert the DevOps engineer. Correct Answer
  2. Create a CloudWatch anomaly detector for the log group. Create a CloudWatch alarm by using metrics that the CloudWatch anomaly detector publishes. Use the high setting for the LogAnomalyPriority metric. Configure the alarm to go into alarm state if a static threshold of one anomaly is detected. Configure the alarm to notify the SNS topic to alert the DevOps engineer.
  3. Create a CloudWatch metrics filter for counted requests on the AWS WAF log group to create a custom metric. Create a CloudWatch alarm that activates when the sum of blocked requests in the custom metric during a period of 1 hour is greater than a static estimate for the acceptable number of blocked requests in 1 hour. Configure the alarm to notify the SNS topic to alert the DevOps engineer.
  4. Create a CloudWatch anomaly detector for the log group. Create a CloudWatch alarm by using metrics that the CloudWatch anomaly detector publishes. Use the medium setting for the LogAnomalyPriority metric. Configure the alarm to go into alarm state if a sum of anomalies over 1 hour is greater than an expected value. Configure the alarm to notify the SNS topic to alert the DevOps engineer.

Community Votes

A
100%

100% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

The requirement to alert only on changes in blocked traffic is met by making the custom metric specific to blocked requests via the metrics filter, so unrelated WAF log activity never enters the metric (A). The requirement to detect sudden change without maintaining a threshold is met by CloudWatch anomaly detection, which adapts as the rules are tuned over time (A). Options B and D use log anomaly detection on the log group, which analyses the log content as a whole and would raise anomalies for changes other than blocked traffic, and options C and D rely on static thresholds, which do not adapt as the rules change.

The alert must fire on sudden changes in blocked traffic and must not fire on other changes in WAF log behavior. A CloudWatch Logs metrics filter that matches blocked requests on the aws-waf-logs log group creates a custom metric counting only blocked requests, which scopes the signal to exactly the behavior of interest. A CloudWatch alarm on that published custom metric using CloudWatch anomaly detection learns the normal pattern of blocked traffic and fires only on a deviation, so there is no fixed threshold to maintain as WAF rules are tuned, and the alarm notifies the existing SNS topic.

Creating a metric filter for counted requests rather than blocked requests (C) — counting all requests dilutes the signal with traffic the requirement is not concerned about, and a static threshold on the sum does not detect sudden changes without manual retuning. Using a CloudWatch anomaly detector on the log group and its LogAnomalyPriority metric (B and D) — as Slays noted, log anomaly detection analyses the log content as a whole, so it would raise anomalies for changes in AWS WAF log behavior other than blocked traffic, which the company explicitly does not want alerts for; CHRIS12722222 also rejected the one-hour period in C because a blocked-request spike could normalize within an hour and be missed.

Community Discussion (4 comments)

Srikantha 👍 1 Selected: A
Option A is the most efficient solution because it directly monitors blocked requests through a custom CloudWatch metric and uses CloudWatch anomaly detection to identify significant deviations, which is precisely what the company needs to monitor.
CHRIS12722222 👍 3 Selected: A
I go with option A if we want to detect SUDDEN change in blocked request, we cant do so in 1hr period as that would be too long a time and what if the blocked request normalised quickly within that 1hr. I think using anomaly detection will provide some upper and lower limit and free us from defining and tuning a static threshold
Slays 👍 1 Selected: C
Unc the question said: "The company does not want to receive alerts for other changes in AWS WAF log behavior" They only want notifications when blocked traffic increase, so anomaly detection doesn't fit the requirements. Gotta be C
uncledana 👍 3 Selected: A
Option A provides the most precise and scalable solution to meet the company’s requirements. It focuses on blocked requests, uses anomaly detection for adaptive monitoring, and provides alerting through SNS when a sudden change in blocked traffic occurs.

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why the Answer Is Correct

The company needs alerts on sudden changes in blocked traffic specifically, and explicitly does not want alerts for other changes in AWS WAF log behavior. The first step is therefore to make the signal specific: a CloudWatch Logs metrics filter that matches blocked requests on the aws-waf-logs log group creates a custom metric whose data consists only of blocked-request activity, so nothing else that happens in the WAF logs can influence it (A). uncledana identified this as the most precise approach, noting that the option focuses on blocked requests. The second requirement is detecting a sudden change without maintaining thresholds as the WAF rules are tuned over time, which is what CloudWatch anomaly detection provides: an alarm is created using CloudWatch anomaly detection on the published custom metric, so the alarm learns the baseline of normal blocked traffic and fires on a statistical deviation rather than on a fixed value that would need constant adjustment (A). The alarm then notifies the existing SNS topic, alerting the DevOps engineer (A). Srikantha described this as the most efficient solution because it monitors blocked requests through a custom metric and uses anomaly detection to identify significant deviations, which CHRIS12722222 reinforced as the way to detect a sudden change in blocked requests. A is the correct answer.

Why the Other Options Are Wrong

B creates a CloudWatch anomaly detector for the log group and an alarm on the metrics it publishes, using the LogAnomalyPriority metric with a high setting and a static threshold of one anomaly. Log anomaly detection analyses the log content as a whole, so it would raise anomalies for changes in WAF log behavior other than blocked traffic, which the company explicitly does not want to be alerted about. D does the same thing with a medium LogAnomalyPriority setting and a sum of anomalies over an hour exceeding an expected value, inheriting the same defect that the analysis is not scoped to blocked requests. C creates a metrics filter for counted requests rather than blocked requests, then alarms when the sum of blocked requests over one hour exceeds a static threshold. Counting all requests rather than blocked requests dilutes the signal with traffic of no interest, and a static threshold neither detects sudden changes nor adapts as the rules are tuned; CHRIS12722222 objected that a one-hour period is too long because a blocked-request spike could normalize within that hour and never trigger the alarm. A is correct.

Community Comment Notes

Community voted A (88). Srikantha explained that option A is the most efficient because it directly monitors blocked requests through a custom CloudWatch metric and uses CloudWatch anomaly detection to identify significant deviations, which is what the requirement asks for. CHRIS12722222 supported A on the specific grounds that a sudden change in blocked requests cannot be detected over a one-hour period, since the spike could normalize within that window. uncledana described A as the most precise and scalable solution because it focuses on blocked requests and uses anomaly detection for adaptive monitoring. Slays was the sole dissenter, preferring C and arguing that anomaly detection is not wanted because only blocked-traffic increases should notify; that reasoning inverts the requirement, since the company explicitly wants sudden changes in blocked traffic detected and only the metrics filter in A scopes the signal to blocked requests. No alternative received support.

Official Reference

Related Analysis

Practice All DOP-C02 Questions

Access 85 questions with complete answers and detailed explanations.

View Full DOP-C02 Practice Test →

← Back to DOP-C02 Study Guide