To query events older than 90 days across multiple regions, use the custom query feature in the ActionTrail console with filter conditions or SQL statements.
Prerequisites
A trail is created and delivers events to Simple Log Service (SLS). Create a single-account trail or Create a multi-account trail.
Use cases
Custom queries support two modes: simple query for visual search, and SQL query for flexible search using Structured Query Language (SQL).
|
Mode |
Query method |
Description |
Example |
|
Simple query |
Single-condition query |
Query events by filter conditions: service name, region, event name, account type, read/write type, resource name, resource type, or operator. |
To query all events for Key Management Service (KMS) within a specified time range, set Service Name to Key Management Service (KMS). |
|
Multi-condition query |
Query events across multiple services or regions. |
To query KMS events in the China (Hangzhou) and China (Shanghai) regions, set Service Name to Key Management Service (KMS) and Alibaba Cloud Region to China (Hangzhou) and China (Shanghai). |
|
|
SQL query |
Keyword query |
Enter search terms to match events. |
To query all write events, enter |
|
Condition-based query |
Filter by operator (Who), operation (What), resource (Which), location (Where), or other attributes. |
To query all events for KMS within a specified time range, enter |
|
|
Multi-condition query |
Combine multiple conditions across operator (Who), operation (What), resource (Which), location (Where), and other attributes. |
To query events generated by the user Alex in ActionTrail, enter |
|
|
Exclusion query |
Use the NOT operator to exclude specific conditions from the query. |
To query events generated by users other than Alex in ActionTrail, enter |
Procedure
-
Log on to the ActionTrail console.
-
In the left-side navigation pane, choose .
-
In the Query Range section, select a trail from the Trail drop-down list.
-
On the Default tab of the Custom Template page, set the query conditions.
-
Simple query
In Simple Mode, set the query conditions as prompted.
-
SQL query
Turn off the Simple Mode switch and enter your SQL query.
Note-
SQL syntax and query examples: SQL syntax for Advanced Event Query.
-
To start from a simple query, set conditions in Simple Mode mode, then turn off the Simple Mode switch. Conditions set in Simple Mode mode are automatically converted into a customizable SQL statement.
-
-
-
Specify a time range and click Run.
Note-
By default, ActionTrail queries events from the past seven days.
-
Click Event Alerting on the right to configure an alert for the current query. Create a custom alert rule.
-
Modify the default SQL statement in the system template, then click Save to save it as a custom template.
-
-
View the query results.
-
Raw log
On the Raw Logs tab, find the target event and click View Details in the Actions column to view basic information and JSON details.
-
Histogram
The Query Histogram tab displays a histogram of the events.
-
Related topics
-
Use system templates to quickly query events: Query events related to an Alibaba Cloud account or AccessKey, Query events related to network and data security best practices, and Query resource lifecycle events.
-
Query events older than 90 days using other methods: Query events in the SLS or OSS console.