This topic describes how to monitor the use of an AccessKey through ActionTrail. You can view the use of an AccessKey in the last 30 days by checking historical events and monitor the AccessKey by configuring a trail and delivering the trail events to the Log Service.
Query historical events
You can view the trail events that occurred in the last 30 days after activating the ActionTrail service.
- Log on to the ActionTrail console.
- In the left-side navigation pane, click History Search.
- From the Filter drop-down list, select AccessKeyId.
- Enter your AccessKeyId to search for a trail event.
Note By switching the region in the upper-left corner, you can view the trail events used by the AccessKeyId of different regions.
Use a trail
ActionTrail allows you to monitor an AccessKey by delivering a trail event to the Log Service.
- In the left-side navigation pane, click Trail List.
- Click Create Trail.
- If you select Delivery to Log Service, set the Log Service Region and Log Service Project.
Note The project is used to store ActionTrail logs. You can enter a project name under the region you selected, or enter a new project name.
- Select Enable logging.
- Click Submit.
ActionTrail automatically delivers the trail events of all regions to the specified Logstore after you successfully create a trail.
Configure Log ServiceLog Service has multiple features, including data analysis, reporting, and alarming. The following is an example of how to set an alarm.
- Log on the Log Service console.
- Click a project.
- On the Logstores page, select a Logstore and click Search.
- Specify the Logstore, topic, and query SQL statement as required, and search for the specified logs.
Note You can click Save Search in the upper-right corner of the page to save the parameters for quick search.
Query SQL statement example:
event.userIdentity.accessKeyId: "LTAI********2qPu" | select count(1) as use_ak_LTAI********2qPu
- Create an alarm according to the saved search and click Saved as Alarm in the upper-right corner of the page.
Note If you set Check Interval to 5, data in the last 10 minutes is checked at an interval of 5 minutes. If the
accessKeyId(such as LTAI********2qPu) is used once in 10 minutes, an alarm is generated.
The following is an alarm example:
Log Service supports various alarm types, for example, notifications, SMS, WebHook-DingTalk Bot, and WebHook-Custom. You can select an appropriate type as needed.