Sub topic 3
Management, data, and Insights events
This chapter explains the three event categories CloudTrail uses and how they decide what gets recorded. It assumes you can read a CloudTrail event record (the previous chapter), know basic IAM and S3 concepts, and can run AWS CLI commands. By the end you should be able to choose which categories to log for a given account and avoid the most common coverage mistakes.
Why categories exist
Every call to an AWS API can be logged, but the volume differs enormously. Creating an IAM role happens a few times a day. Reading an S3 object can happen millions of times an hour. If CloudTrail recorded everything by default, the logs would be huge and expensive, and most of the content would be noise for an audit.
CloudTrail therefore sorts events into categories. Each category has its own default behavior, its own cost, and its own way of being switched on.
| Category | What it captures | Recorded by default? | Typical question it answers |
|---|---|---|---|
| Management events | Control-plane operations on resources | Yes, in Event history | Who changed this configuration? |
| Data events | Data-plane operations on or inside resources | No | Who read or deleted this object? |
| Insights events | Unusual API call rates or error rates | No | Did something change in our normal activity pattern? |
In the event record, the eventCategory field holds the category value, for example Management, Data, or Insight. You use that same field name when you write event selectors.
Management events
Management events (also called control plane events) record operations that create, configure, or delete resources, and operations that manage security and routing. Examples:
- IAM:
CreateUser,AttachRolePolicy,PutUserPolicy - EC2:
RunInstances,AuthorizeSecurityGroupIngress,TerminateInstances - CloudTrail itself:
StopLogging,DeleteTrail,UpdateTrail - Console sign-in:
ConsoleLogin - S3 bucket-level calls such as
CreateBucket,PutBucketPolicy, andDeleteBucket
The event in the previous chapter, StopLogging on org-audit-trail, is a management event. These are the events most audits start with, because they show changes to your security posture.
Read-only and write-only
Each management event has a readOnly field. Read-only events such as DescribeInstances or ListBuckets do not change anything. Write events such as RunInstances do. When you configure a trail you can record reads, writes, or both.
Read-only management events are often the most numerous because monitoring tools and consoles poll constantly. Excluding them lowers volume, but it also means you lose evidence of reconnaissance. An attacker who has stolen credentials often calls ListBuckets and GetCallerIdentity before doing anything destructive. If you only log writes, you will not see that preparation.
What you get for free
Without creating anything, CloudTrail records management events for the last 90 days in Event history, per Region. This covers write and read management events. Event history is useful for quick checks, but it is not a durable audit log: it expires, it is limited to one Region at a time in the console and CLI, and it excludes data events. A trail is what gives you long-term retention. The next chapters cover both.
The first copy is free
The first copy of management events delivered by a trail in each Region is free of CloudTrail charges (you still pay for S3 storage). A second trail that records the same management events in the same Region is billed. Plan for one trail that covers everything rather than several overlapping trails.
Data events
Data events (also called data plane events) record operations performed on or inside a resource, not operations that manage the resource itself. They are off by default because of their volume. Common examples:
- S3 object-level API calls:
GetObject,PutObject,DeleteObject - Lambda function invocations:
Invoke - DynamoDB item-level calls such as
PutItemandGetItem
Many more services support data events. Each one is identified by a resource type string, for example AWS::S3::Object, AWS::Lambda::Function, or AWS::DynamoDB::Table. Check the CloudTrail documentation for the current list, because AWS adds resource types over time.
Why this matters for audits
Suppose a bucket of customer files is leaked. Management events can tell you that someone changed the bucket policy. They cannot tell you which objects were downloaded. Only data events show that, and only if they were enabled before the incident. CloudTrail does not record past activity retroactively, so a data event you did not enable is a gap you cannot fill later.
Choosing what to record
Because data events are high volume, you select them narrowly. Advanced event selectors filter on fields such as:
eventCategory(required:Data)resources.typeresources.ARN, with operators likeEqualsandStartsWitheventNamereadOnly
The command below records management events plus object-level data events for one sensitive bucket only.
aws cloudtrail put-event-selectors \
--trail-name org-audit-trail \
--advanced-event-selectors '[
{
"Name": "Management events",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Management"] }
]
},
{
"Name": "S3 object-level events for one bucket",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::S3::Object"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:s3:::my-sensitive-bucket/"] }
]
}
]'Note the trailing slash in the ARN prefix. Object ARNs have the form arn:aws:s3:::bucket-name/key, so the slash limits the match to objects in that bucket. Without it, StartsWith would also match a bucket called my-sensitive-bucket-archive.
A narrower selector can also skip noise. For example, you can add { "Field": "readOnly", "Equals": ["false"] } to record only writes and deletes, which keeps cost low while still capturing tampering.
Basic and advanced selectors
CloudTrail has two selector styles. Basic event selectors can only choose read/write type and a small set of resource types. Advanced event selectors can filter on many fields and cover more resource types. A trail uses one style or the other, not both at once. Prefer advanced selectors for new work. Note that put-event-selectors replaces the entire existing selector set, so always include the management events block when you update a trail, or you will silently stop recording them.
Insights events
Insights events are generated by CloudTrail itself. They are not API calls that someone made. CloudTrail builds a baseline of your normal write management activity (and, optionally, API error rates), then logs an Insights event when the pattern departs from that baseline.
Two Insights types exist:
ApiCallRateInsight: the rate of write management API calls is unusual. For instance, a normal day has 5RunInstancescalls and today there are 800.ApiErrorRateInsight: the rate of errors such asAccessDeniedorThrottlingfor an API is unusual. A burst ofAccessDeniederrors can indicate credential probing or a broken deployment.
Points to know:
- Insights must be enabled on a trail, and a trail must already record the corresponding management events. Insights analyzes what the trail records.
- An Insights event has a start and an end. CloudTrail logs one when the unusual period begins and another when it ends, so you can see the duration and the size of the change.
- Insights events are delivered to a separate prefix in the S3 bucket (
CloudTrail-Insight), not mixed in with ordinary logs. - They are billed by the number of events analyzed, so they add cost on top of the trail.
- Insights does not tell you who did it or whether the activity is malicious. It tells you where to look. You then query the underlying management events for that time window.
The flow looks like this.
Enabling Insights from the CLI
Turn on both Insights types for an existing trail:
aws cloudtrail put-insight-selectors \
--trail-name org-audit-trail \
--insight-selectors '[
{"InsightType": "ApiCallRateInsight"},
{"InsightType": "ApiErrorRateInsight"}
]'Insights needs time to learn a baseline, so you will not get events immediately. Expect delays of up to about 36 hours before the first Insights events can appear.
Choosing what to log
A practical starting point for most accounts:
- Record all management events, reads and writes, in every Region. This covers the changes and the reconnaissance.
- Record data events only for resources whose access you must prove: buckets with regulated or customer data, critical Lambda functions, sensitive DynamoDB tables.
- Within those resources, start with writes and deletes if cost is a concern, and add reads for the most sensitive ones.
- Enable Insights if you have a team that will act on the alerts, and route them somewhere visible.
Common errors
- Assuming data events are on. Teams discover during an incident that
GetObjectwas never recorded. - Overwriting selectors and dropping management events (see the warning above).
- Using a
StartsWithARN without a trailing slash, which matches more buckets than intended. - Enabling data events for all S3 buckets in an account that has a busy data pipeline. The log volume and bill can be larger than the pipeline's compute cost.
- Expecting Event history to show data events. It does not.
- Expecting Insights to work without management events on the trail.
Checking what a trail records
Verify your configuration instead of trusting memory:
aws cloudtrail get-event-selectors --trail-name org-audit-trail
aws cloudtrail get-insight-selectors --trail-name org-audit-trailThe first command returns the advanced selectors you configured. The second shows which Insights types are active. Run these after every change and keep the output in your change records.
Exercise
A security team enabled a trail last month with default management event settings. After a data leak, they want to know which objects in customer-exports were downloaded last week. Can the trail answer this? What would they have needed to do beforehand, and what should the selector look like?
Show answer
No. Downloads are S3 GetObject calls, which are data events, and data events are not recorded unless selected. Event history and a management-only trail contain only bucket-level calls such as PutBucketPolicy. Beforehand they needed an advanced event selector with eventCategory equal to Data, resources.type equal to AWS::S3::Object, and resources.ARN starting with arn:aws:s3:::customer-exports/. Logging does not apply retroactively, so last week's reads cannot be recovered from CloudTrail.
Exercise
You run put-event-selectors with a single data event selector for one Lambda function. The next day, nobody can find CreateUser events in the trail's S3 logs. What happened, and how do you fix and prevent it?
Show answer
put-event-selectors replaces the whole selector set, so the management events selector was removed and the trail stopped recording management events. Fix it by sending the full list again, including a selector with eventCategory equal to Management, alongside the Lambda data selector. To prevent it, run get-event-selectors first, edit the complete list, and send it back. Events during the gap are lost from the trail, although Event history still holds the last 90 days of management events in that Region.
Exercise
Your Insights event says ApiCallRateInsight for TerminateInstances between 02:10 and 02:40. What does it tell you, what does it not tell you, and what is your next step?
Show answer
It tells you that the rate of TerminateInstances write calls was unusually high in that window compared with the baseline. It does not identify the caller, the instances, or whether the activity was malicious. The next step is to query the underlying management events for TerminateInstances between 02:10 and 02:40, using lookup-events or a query tool, and read userIdentity, sourceIPAddress, and requestParameters in each record.