Configuring alerts for the service
Alerting allows you to monitor changes in metrics and notifies you when they hit critical levels using periodic queries known as alerts. When metrics reach threshold values, the system sends a notification via the specified communication channel, e.g., by email or messenger.
Smart Web Security offers these incoming request rate metrics:
load_balancer.smart_web_security.requests_per_second: Number of requests sent to the protected resource per second. This value matches the number of requests processed by the security profile.load_balancer.smart_web_security.arl_requests_per_second: Number of requests sent to the protected resource per second, processed by Advanced Rate Limiter.
You can configure alerts for metrics reaching the specified rate thresholds. You can also use labels to track metrics by individual events.
To configure alerting:
- Create a notification channel.
- Select metrics and labels for monitoring.
- Create an alert.
Let's take a look how you can create some alerts to detect anomalies:
Alert for increased percentage of blocked requests
The alert will be triggered when the number of blocked requests reaches 50% or more of the total requests. This alert helps detect different types of attacks, e.g., DDoS or bot-based hack attempts.
Let's use letters to indicate the number of incoming requests per second:
A: Total requests.B: Number of requests blocked by the security profile.
Let's set up our alerts:
Breaches 30% ofA:Warning.Breaches 50% ofA:Alarm(critical level).
Creating a notification channel
-
In the management console
, select the folder on the left. -
Select Monitoring.
-
Go to the Notification channels section.
-
Click Create channel.
-
Specify the channel name, notification method, and recipients.
Note
To get notifications, the user must:
- Have the
monitoring.viewerrole for the folder with the configured alert. - In the management console settings
:- Enable Monitoring.
- Specify an email address, phone number, and Telegram account or group.
- Have the
-
Click Create.
Selecting metrics for monitoring
- We will get the
Avalue using theload_balancer.smart_web_security.requests_per_secondmetric. - We will get the
Bvalue using theload_balancer.smart_web_security.requests_per_secondmetric filtered by theantirobot_verdict=denylabel. - We will calculate the
BtoAratio (in percent) using the100 * B / Aformula and save it asC.
Creating an alert
-
On the Monitoring home page, click Create alert.
-
Name your alert, e.g.,
exceeding-blocked-requests. -
Under Alerts config, describe your query to get the
Avalue:- Click
next to and add these settings:
service=Application Load Balancername=load_balancer.smart_web_security.requests_per_secondantirobot_verdict=allowload_balancer=<load_balancer_name>.
- Click
next to . - Set the
replace_nan(0)function to replace missing data with0, ensuring a continuous chart.
- Click
-
Click Add query.
-
Describe your query to get the
Bvalue:- Specify the data to collect:
service=Application Load Balancername=load_balancer.smart_web_security.requests_per_secondantirobot_verdict=denyload_balancer=<load_balancer_name>
- Set the
replace_nan(0)function.
-
Click Add query.
-
Describe you query for
Cto get theBtoAratio in percent:- Click
to switch to text mode to edit the query. - Enter
100 * B / Ain the query string.
- Click
-
Under Alert parameters, specify:
Query to evaluate:CAggregation function:All valuesWarning:30Alarm:50(critical level)Evaluation window:30 secondsEvaluation delay:15 seconds
-
Leave the default values under No data policy.
-
Optionally, under Annotations, add the information to log when the alert is triggered.
-
Under Notifications, add the notification channel.
-
Click Create.
Alert for a high rate of legitimate requests
Let's use letters to indicate the number of incoming requests per second:
A: Allowed by the security profile.B: Allowed by the ARL profile.
Normally, A must be slightly greater or equal to B. In other words, the number of requests allowed by the security profile slightly exceeds the limit set in the ARL profile. This means that most requests allowed by the security profile reach the virtual host. In this case, the system load remains within normal limits.
A significant difference in the number of requests means the system cannot handle the load and blocks potentially legitimate requests. This can be due to insufficient capacity or an attack. If this situation persists, we recommend reviewing your security profile settings or rate limits.
Let's set up alerts to detect exceeded rate limits:
AexceedsBby 30%:Warning.AexceedsBby 50%:Alarm(critical level).
Creating a notification channel
-
In the management console
, select the folder on the left. -
Select Monitoring.
-
Go to the Notification channels section.
-
Click Create channel.
-
Specify the channel name, notification method, and recipients.
Note
To get notifications, the user must:
- Have the
monitoring.viewerrole for the folder with the configured alert. - In the management console settings
:- Enable Monitoring.
- Specify an email address, phone number, and Telegram account or group.
- Have the
-
Click Create.
Selecting metrics for monitoring
- We will get the
Avalue using theload_balancer.smart_web_security.requests_per_secondmetric filtered by theantirobot_verdict=allowlabel. - We will get the
Bvalue using theload_balancer.smart_web_security.arl_requests_per_secondmetric filtered by thearl_verdict=allowlabel. - We will calculate the excess of
AoverB(in percent) using the100 * abs(A - B) / Bformula and save it asC.
Creating an alert
-
On the Monitoring home page, click Create alert.
-
Name your alert, e.g.,
inbound-over-ARL. -
Under Alerts config, describe your query to get the
Avalue:- Click
next to and add these settings:service=Application Load Balancername=load_balancer.smart_web_security.requests_per_secondantirobot_verdict=allowload_balancer=<load_balancer_name>.
- Click
next to and set the data processing functions:series_sum(): Sum of metrics with different labels for a particular point. In our example, there is one label (antirobot_verdict), but this function will be useful for other metrics.replace_nan(0): Replaces missing data with0for a continuous chart.
- Click
-
Click Add query.
-
Describe your query to get the
Bvalue:- Specify the data to collect:
service=Application Load Balancername=load_balancer.smart_web_security.arl_requests_per_secondarl_verdict=allowload_balancer=<load_balancer_name>
- Set the
series_sum()andreplace_nan(0)functions.
- Specify the data to collect:
-
Click Add query.
-
Describe your query for
Cto get the difference betweenAandBin percent:- Click
to switch to text mode to edit the query. - Enter
100 * abs(A - B) / Bin the query string.
- Click
-
Under Alert parameters, specify:
Query to evaluate:CAggregation function:All valuesWarning:30Alarm:50(critical level)Evaluation window:30 secondsEvaluation delay:15 seconds
-
Leave the default values under No data policy.
-
Optionally, under Annotations, add the information to log when the alert is triggered.
-
Under Notifications, add the notification channel.
-
Click Create.