Sub topic 3
Management, data, and Insights events
This chapter assumes you can read a CloudTrail event record, know basic IAM and S3 concepts, and can run the AWS CLI. Every CloudTrail event belongs to an event category. The category decides whether CloudTrail records the event by default, whether it costs extra, and which settings you must change to capture it.
The three categories
CloudTrail groups events into management events, data events, and Insights events. The eventCategory field in a record names the category.
| Category | What it records | On by default? | Typical example |
|---|---|---|---|
| Management | Control-plane operations that create, change, or delete resources, plus sign-ins | Yes, in Event history | `RunInstances`, `PutUserPolicy`, `StopLogging` |
| Data | Data-plane operations on the contents of a resource | No | `GetObject` on an S3 object, `Invoke` on a Lambda function |
| Insights | Unusual call volume or error rates, derived from your management events | No | A sudden spike in `TerminateInstances` calls |
Management events
Management events describe operations on the resources in your account. They are also called control-plane events. Creating an IAM user, changing a security group, and stopping a trail are all management events. Console sign-ins are recorded in this category too.
Management events are split into read and write events. A read event, such as DescribeInstances, does not change anything. A write event, such as DeleteBucket, does. The readOnly field in the record tells you which one you are looking at. A trail can record only reads, only writes, or both. For most audits you need writes. Reads become important when you investigate reconnaissance, such as someone listing all your buckets.
Data events
Data events describe operations on the data inside a resource. They are also called data-plane events. Reading an S3 object, writing to a DynamoDB table, and invoking a Lambda function are data events.
Data events are off by default because they are high volume and are billed per event. You turn them on per resource type, and you can narrow them to specific resources. The put-event-selectors example below records management events plus S3 object-level events for one 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/"] }
]
}
]'The trail now records object reads and writes in my-sensitive-bucket only. Objects in other buckets are not logged at the object level.
Insights events
Insights events are generated, not directly caused by one API call. CloudTrail builds a baseline of normal write-management activity in your account. When the call rate or error rate differs from that baseline, it records an Insights event.
Insights is useful for spotting problems you did not think to write a rule for. Examples include a script stuck in a retry loop, or a compromised key making an abnormal number of calls. Insights is off by default and billed separately. It analyzes management events, so the trail must record write management events for Insights to work.
Choosing what to log
Use these guidelines:
- Always log management events, both read and write, in at least one trail. Event history keeps only 90 days, so a trail gives you the long-term record.
- Enable data events only for resources whose contents matter, such as buckets holding sensitive data. Scope them by ARN instead of logging every bucket.
- Add Insights when you want automatic detection of unusual activity and accept the extra cost.
Common errors
- Expecting object access in Event history. Event history shows management events only.
GetObjectnever appears there. - Logging all S3 data events. Selecting every bucket can produce very large log volumes and a high bill. Filter on
resources.ARN. - Enabling Insights without write management events. Insights has nothing to analyze.
Exercise
A teammate says a file was downloaded from a sensitive S3 bucket last week, but aws cloudtrail lookup-events finds no GetObject events. Which category explains this, and what should have been configured?
Show answer
GetObject is a data event. lookup-events and Event history cover management events only. A trail (or event data store) needed data events enabled for the bucket's objects, for example with an advanced event selector for AWS::S3::Object with resources.ARN starting with the bucket ARN. If that was not set up before the download, the event was not recorded.