Create custom alert rules to monitor specific events for flexible enterprise security monitoring. ActionTrail generates alerts based on the queries, check frequency, and trigger conditions that you configure, then performs alert denoising and sends notifications based on your alert policies and action policies.
Background information
Custom alert rules use Structured Query Language (SQL) syntax to filter events. For more information about the SQL syntax, see Query overview and Query and analysis overview.
Procedure
-
Log on to the ActionTrail console.
-
In the left-side navigation pane, click Event Alerting.
-
On the Alert Center page, go to the Alert Rules tab and click Create Alert.
-
In the Create Alert panel, add a query and analysis configuration.
-
Click Add to the right of Query and Analysis.
-
In the Query and Analysis dialog box, on the Advanced Settings tab, set Types to Logstore Name and Authorization Method to Default.
NoteThe Region and Project fields are automatically populated to match the trail where event alerting is enabled.
-
Select the Logstore to which the trail delivers events. The Logstore name is in the format
actiontrail_<trail_name>. -
Select whether to enable Dedicated SQL.
Note-
Auto: Dedicated SQL is disabled by default. If a query concurrency limit is reached or query results are inaccurate, Simple Log Service automatically retries the query with Dedicated SQL.
-
Enable: Enables Dedicated SQL for all queries and analysis.
-
Close: Disables Dedicated SQL.
For more information about Dedicated SQL, see High-performance and high-accuracy query and analysis (Dedicated SQL).
-
-
Set the Query Time Range, enter a custom query statement in the text box to the right of Query, and then click Preview.
For more information about custom query statements, see Custom query statements.
-
Click Confirm.
-
-
In the Create Alert panel, configure parameters such as Rule Name, Check Frequency, Group Evaluation, Trigger Condition, Add Tag, Add Annotation, No Data Recovery, Advanced Settings, and Destination.
For more information about the parameters, see Alert monitoring rule parameters.
-
Click Confirm.
After the custom alert rule is created, it appears in the alert rule list. For more information, see Manage alert rules.
Custom query statements
|
Scenario |
Description |
Custom query statement |
|
Filter by cloud service and event |
Filters events by cloud service and event name. |
|
|
Get and specify parameters |
Filters events by specific parameter values in the |
|
|
Get resources |
Filters events by resource name or type. For more information about the parameters, see Management event structure. |
Get a single resource. For example, get the ID of the affected instance in an ECS instance release event.
|
|
Get identities |
Filters events by the identity that initiated them. The identity information ( |
|
|
Count event occurrences |
Counts event occurrences and triggers an alert when a specified threshold is exceeded. |
|
Custom alert examples
The arbitrary function returns an arbitrary non-null value from x. The syntax is arbitrary(x). For more information, see the arbitrary function. The following examples use this function.
-
Example 1: Alert on ApsaraDB RDS instance release
event.serviceName: RDS and (event.eventName: DeleteDBInstance or event.eventName: Release or event.eventName: DestroyDBInstance) | SELECT account_id, resourceArray[num] as instance_id, ram_user_id, user_type, user_name FROM (SELECT "event.userIdentity.accountId" as account_id, "event.userIdentity.principalId" as ram_user_id, split("event.resourceName", ';') as resourceArray, array_position(split("event.resourceType", ';'), 'ACS::RDS::DBInstance') as num, "event.userIdentity.type" as user_type, "event.userIdentity.userName" as user_name FROM log ) where num > 0 -
Example 2: Alert on security group configuration changes
event.eventName: CreateSecurityGroup OR event.eventName: AuthorizeSecurityGroup OR event.eventName: AuthorizeSecurityGroupEgress OR event.eventName: RevokeSecurityGroup OR event.eventName: RevokeSecurityGroupEgress OR event.eventName: JoinSecurityGroup OR event.eventName: LeaveSecurityGroup OR event.eventName: DeleteSecurityGroup OR event.eventName: ModifySecurityGroupPolicy) | select "event.userIdentity.accountId" as account_id, "event.userIdentity.principalId" as ram_user_id, "event.eventName" as event_name, arbitrary("event.userIdentity.type") as user_type, arbitrary("event.userIdentity.userName") as user_name group by account_id, ram_user_id, event_name
Related documents
-
You can also create custom alert rules in Simple Log Service. For instructions, see Create an alert monitoring rule.
-
After you enable an alert rule, you can manage it in Simple Log Service. For more information, see Manage alert monitoring rules.