Analysing CloudTrail Events with Insights, Athena and EventBridge
This lesson explains how CloudTrail Insights detects unusual activity automatically, and how Athena and CloudWatch Logs make large volumes of events searchable.
Learning outcomes
After completing this lesson, you will be able to:
- Describe what CloudTrail Insights detects.
- Query events with Athena, and explain CloudTrail Lake's status.
- React to API calls in real time with EventBridge.
CloudTrail Insights
CloudTrail Insights learns the normal rate of write management API calls (API call rate insights) and of failed calls (API error rate insights) for an account, and generates an Insights event when activity deviates significantly, such as a burst of TerminateInstances calls or a sudden increase in AccessDenied errors from a misconfigured deployment. Insights events are delivered to the trail's bucket and to EventBridge, so they can trigger notifications.
Querying with Athena, CloudWatch and CloudTrail Lake
Amazon Athena queries trail log files in S3 with SQL. The CloudTrail console can create the Athena table for a trail, and partition projection on account, Region and date keeps queries fast and cheap. A trail that also sends to CloudWatch Logs supports metric filters, alarms and Logs Insights queries for recent events. CloudTrail Lake stores events in event data stores queried with SQL; it was closed to new customers on 31 May 2026, so new designs use trails with Athena or CloudWatch Logs instead, while existing customers can continue to use it.
SELECT useridentity.arn, eventname, count(*) AS calls
FROM cloudtrail_logs
WHERE errorcode = 'AccessDenied'
AND timestamp >= '2026/10/10'
GROUP BY useridentity.arn, eventname
ORDER BY calls DESC
LIMIT 20;Where to analyse events
Reacting to events in real time
CloudTrail management events also flow to the default EventBridge bus as events with detail-type AWS API Call via CloudTrail. An EventBridge rule can react within seconds to a specific call, such as DeleteTrail, PutBucketPolicy or CreateAccessKey, without waiting for log files. The following table compares the ways of acting on CloudTrail data.
| Approach | Latency | Best for |
|---|---|---|
| EventBridge rule on API call events | Seconds | Immediate automated reaction to a specific API call |
| Metric filter and alarm on CloudWatch Logs | Minutes | Counting patterns and alarming on thresholds |
| Athena on S3 log files | Minutes to query, any history | Investigations over months of events |
| CloudTrail Insights | Minutes | Detecting unusual call or error rates without defining thresholds |
The following diagram shows three of the approaches from the table side by side.

Reacting to an API call
Tagging new instances automatically
Finance wants every new EC2 instance tagged with the identity of the person who launched it. An EventBridge rule matches source: aws.ec2, detail-type: AWS API Call via CloudTrail and eventName: RunInstances. Its Lambda target reads detail.userIdentity.arn and the instance IDs from detail.responseElements.instancesSet and calls CreateTags with a CreatedBy tag. Because the rule is Regional, it is deployed to every Region in use with a StackSet.
What makes Athena queries on trail logs efficient as the bucket grows?
Show answer
Partition projection, which limits each query to the relevant partitions.
Exam Tips
Remember for the exam
- CloudTrail Insights detects unusual API call volumes and error rates.
- Query trail logs in S3 with Athena; use partition projection.
- React to a specific API call in seconds with an EventBridge rule on 'AWS API Call via CloudTrail'.
- CloudTrail Lake is closed to new customers (May 2026); prefer trails with Athena or CloudWatch Logs.