By using the alerting feature of Alibaba Cloud Log Service, you can configure custom monitoring charts and alert services for objects that are protected by Web Application Firewall (WAF) and have Log Service enabled to monitor and receive alerts for the overall traffic and security status of your business. This topic describes how to use Log Service to configure monitoring and alerts for WAF.
Background
This topic provides 13 examples of log chart and alert configurations. These examples cover scenarios such as abnormal ratios of 4xx and 5xx status codes, abnormal or sudden changes in QPS, requests blocked by different rule types, common attack patterns, high average delay, and sudden traffic drops.
Prerequisites
-
Your website has been added to WAF. For more information, see Tutorials.
Log Service is enabled for your domain name. For more information, see Quick start for WAF Log Service.
Procedure
-
Log on to the Web Application Firewall (WAF) console. In the top menu bar, select the resource group and region for your WAF instance: Chinese Mainland or Outside Chinese Mainland.
Access the advanced management page for Log Service.
In the left-side navigation pane, choose .
In the upper-right corner of the Simple Log Service page, click Advanced Management.
In the dialog box that appears, click OK.
Create a WAF log analysis dashboard.
In the Projects, find the WAF log project that you want to manage and click the project name.
Enter a query statement and click Search & Analyze.
NoteFor information about the SQL query statements used for monitoring and analysis, see Query and analysis statements.
After the query is complete, click the
icon below the log fields. On the Graph tab, click Add to New Dashboard.In the Add to New Dashboard dialog box, configure the following parameters and click OK.
Parameter
Description
Operation
Select Create Dashboard.
Layout Mode
Select a layout mode for the dashboard.
Dashboard Name
Enter a name for the dashboard.
Configure log charts.
In the upper-right corner of the dashboard, click Edit.
In the dashboard's edit mode, you can edit or delete existing charts, or add new charts by copying an existing one.
NoteYou can copy an existing chart to create a new one. This is an efficient way to add multiple charts for diverse data visualization and alert configurations.
Copy a chart to add a new one
Find the chart you want to copy, move the pointer over the options icon (
) in the upper-right corner, and click Copy. After the chart is copied, an identical chart appears next to the original.
Drag the new chart to a suitable position on the dashboard.
Edit an existing chart
Find the chart you want to edit, move the pointer over the options icon (
) in the upper-right corner, and click Edit.On the Edit page, modify the chart settings as needed, such as Chart Name, SQL query statement, relative time range, and chart type. Then, click OK.
NoteIf you modify the SQL query statement, you must click Preview to validate the syntax before you can click OK. If the statement is invalid, an error message appears and the OK button is disabled. You can click OK only after you correct the statement.
Delete an existing chart
Find the chart you want to delete, move the pointer over the options icon (
) in the upper-right corner, and click Delete.
Configure log alerts.
In the upper-right corner of the dashboard, choose .
On the Create Alert Monitoring Rule page, configure the Alert Configuration settings and click Next.
Parameter
Description
Alert name
The alert name, which must be 1 to 64 characters long.
Association Chart
The charts to associate with the alert.
When you configure an associated chart, the Query Time Range specifies the time range of log data that the server reads for each query. It supports relative time and fixed time. For example, if the query runs at 14:30:06 and you set Query Time Range to 15 minutes (relative), the query range is from 14:15:06 to 14:30:06. If you set Query Time Range to 15 minutes (fixed time), the query range is from 14:15:00 to 14:30:00.
To add multiple charts, click Add. You can associate up to three charts. Each chart is assigned an ID, which is the number displayed before its name. You can use this ID in the trigger condition to reference the chart.
Frequency
The interval at which the server checks the alert condition.
NoteThe server returns only the first 100 entries from the check result.
Trigger Condition
The conditional expression that determines whether to trigger an alert. When this condition is met, the system sends an alert notification based on the specified Execution Interval and Notification Interval.
Charts are numbered starting from 0 by default. In the trigger condition, you can use
$0to refer to the first chart. For example, you can set the trigger condition to$0.domainnum>=10. This means an alert is triggered if the value of thedomainnumfield in the first chart is greater than or equal to 10.Use
&&for a logical AND (all conditions must be met) and||for a logical OR (at least one condition must be met).NoteFor more information about the syntax of alert condition expressions, see Alert condition expression syntax.
Advanced Options
Notification Trigger Threshold
When the cumulative number of triggers reaches this threshold, an alert is sent according to the Notification Interval. If the trigger condition is not met, the trigger is not counted. The default Notification Trigger Threshold is 1. This means that the system checks the Notification Interval after the Trigger Condition is met once.
By configuring this threshold, you can require a condition to be met multiple times before sending a single notification. For example, if you set the threshold to 100, the system checks the Notification Interval only after the trigger condition has been met 100 times. A notification is sent if both the Notification Trigger Threshold and Notification Interval are met. After a notification is sent, the cumulative count is reset to zero. If a check fails due to an issue like a network error, the count is not incremented.
NoteFor more information about the monitoring metrics used in alert configurations and recommended threshold settings, see Common monitoring metrics.
Notification Interval
The time interval between two consecutive alert notifications.
If a check meets the trigger condition, the cumulative trigger count has reached the Notification Trigger Threshold, and the notification interval has elapsed since the last notification, a new notification is sent. For example, if you set the notification interval to 5 minutes, you will receive at most one notification for this alert every 5 minutes. By default, no interval is specified.
NoteBy configuring the notification trigger threshold and notification interval, you can suppress alerts and reduce alert noise.
NoteThe Notification Trigger Threshold, Notification Interval, and Frequency settings work in conjunction. Log Service checks for the trigger condition at the specified check frequency. An alert is sent when the trigger count reaches the Notification Trigger Threshold within the specified Notification Interval.
On the Create Alert Monitoring Rule page, configure the Notification settings and click Submit.
Select a method from the Notifications and then configure it. Log Service supports several notification methods, such as SMS, Voice, Email, and WebHook-DingTalk Bot. You can select and configure multiple notification methods.
SMS alert
Set the Mobile Phone Number and Send Content. You can include alert fields in the content. Click View All Variables to see the description of each variable.
Voice alert
Set the recipient's Mobile Phone Number and Send Content.
Email alert
Set the Recipient, Subject, and Send Content.
WebHook-DingTalk Bot
Set the Request URL, which is the webhook URL for the DingTalk bot, and specify the Send Content.