Sub topic 2
Reading a CloudTrail event record
This chapter assumes you can read JSON, know the basics of IAM users, roles, and policies, and can run AWS CLI commands. Every CloudTrail feature in this tutorial, from Event history to alerts, works on the same unit: the event record. Once you can read one record, you can read all of them.
What an event record is
CloudTrail writes one JSON object for each recorded API call or account event. The record describes a single request: who made it, what they asked for, where it came from, and what happened. CloudTrail does not store the full state of your resources, and it does not store the contents of the objects or items you work with. It stores the request metadata.
Here is the trimmed record used throughout this chapter:
{
"eventVersion": "1.09",
"userIdentity": {
"type": "IAMUser",
"arn": "arn:aws:iam::123456789012:user/alice",
"accountId": "123456789012",
"userName": "alice"
},
"eventTime": "2026-11-20T09:15:42Z",
"eventSource": "cloudtrail.amazonaws.com",
"eventName": "StopLogging",
"awsRegion": "us-east-1",
"sourceIPAddress": "203.0.113.10",
"userAgent": "aws-cli/2.x",
"requestParameters": { "name": "org-audit-trail" },
"readOnly": false,
"eventType": "AwsApiCall",
"recipientAccountId": "123456789012"
}Real records usually have more fields, such as eventID, requestID, responseElements, and tlsDetails. The trimmed version keeps the ones you use in almost every investigation.
Mapping questions to fields
An audit question usually has five parts: who, what, when, where from, and on what. Each part maps to specific fields.
| Question | Fields | In the example |
|---|---|---|
| Who | `userIdentity` | IAM user `alice` in account `123456789012` |
| What | `eventSource`, `eventName` | `StopLogging` on the CloudTrail service |
| When | `eventTime` | 2026-11-20 09:15:42 UTC |
| Where from | `sourceIPAddress`, `userAgent` | `203.0.113.10`, using the AWS CLI |
| On what | `requestParameters` | A trail named `org-audit-trail` |
| Outcome | `errorCode`, `errorMessage` | Absent, so the call was not rejected |
Read the example as a sentence: on 20 November at 09:15 UTC, IAM user alice, using the AWS CLI from 203.0.113.10, told CloudTrail to stop logging the trail org-audit-trail. That is a sensitive action. Someone who wants to hide activity may stop a trail first.
The fields in detail
userIdentity: who made the call
userIdentity is the most important block and the one with the most variation. Its type field tells you which other fields to expect.
| `type` | Meaning | Where to look for the person or system |
|---|---|---|
| `Root` | The account root user | No user name. Check `arn` and the IP address. |
| `IAMUser` | A long-term IAM user | `userName` and `arn` |
| `AssumedRole` | Temporary credentials from a role | `arn` ends with the session name. See `sessionContext`. |
| `FederatedUser` | A user from a federation call | `arn` and `sessionContext` |
| `AWSService` | An AWS service acting on your behalf | `invokedBy` |
| `AWSAccount` | A principal from another account | `accountId` |
The AssumedRole type is the one that surprises people. The arn looks like this:
arn:aws:sts::123456789012:assumed-role/DeployRole/build-4821The part after the role name, build-4821, is the role session name. A person or tool chooses it when calling AssumeRole, so it is a label, not proof of identity. For a role session, the sessionContext block holds more detail:
sessionIssuernames the role that was assumed.attributes.creationDateshows when the session started.attributes.mfaAuthenticatedshows whether MFA was used to get the credentials.sourceIdentity, if set, carries an identity that stays with the session through chained role assumptions.
To find the human behind an assumed-role call, you often need a second search. Look up the earlier AssumeRole or AssumeRoleWithSAML event that created the session, and read its userIdentity and sourceIPAddress.
eventTime, eventSource, and eventName
eventTime is in UTC and uses ISO 8601 format, so convert it before you compare it with local logs. Events are not delivered the moment they happen. A trail typically delivers log files to S3 about five minutes after the activity, so a record that is missing from S3 right now may arrive shortly.
eventSource is the service endpoint, such as s3.amazonaws.com or iam.amazonaws.com. eventName is the API action, such as PutBucketPolicy or CreateAccessKey. Two cautions apply:
eventNameis the API name, not the CLI subcommand. The commandaws s3 cpproduces events likePutObjectorGetObject.- Console sign-in appears as
ConsoleLogin, and the result is inresponseElements.ConsoleLogin(SuccessorFailure).
To match one action precisely, filter on both eventSource and eventName. Several services can share an action name.
awsRegion and recipientAccountId
awsRegion is the Region that received the request. Global services such as IAM log to us-east-1, so IAM changes appear there regardless of where the caller was. recipientAccountId is the account that received the event. In an organization trail or with cross-account access, it can differ from the account in userIdentity, which is the first thing to check when a call looks like it came from outside.
sourceIPAddress and userAgent
sourceIPAddress is the address of the caller as AWS saw it. It has some special values:
- A service endpoint name, such as
cloudformation.amazonaws.com, means an AWS service made the call for the principal. AWS Internalmeans AWS itself made the call.- Calls from a VPC through a VPC endpoint can show a private address.
userAgent identifies the client. Typical values include aws-cli/2.x ..., Boto3/..., a browser string for console actions, or console.amazonaws.com. Callers control this string, so it can be spoofed. Use it as a clue, for example a human account suddenly calling from a script SDK, but not as proof.
requestParameters and responseElements
requestParameters holds what the caller asked for, and responseElements holds part of what AWS returned. In the example, requestParameters names the trail. Three edge cases matter:
- Read-only calls often have
responseElementsset tonull. - Secret values are replaced with
HIDE_VALUE. For example, a returned secret access key does not appear in the log. - Some services leave out request fields, or shorten large ones. Never assume a missing parameter means the caller did not send it.
errorCode and errorMessage
These fields appear only when the call failed. Common values are AccessDenied, UnauthorizedOperation, and ThrottlingException. Failed calls are useful evidence. A burst of AccessDenied events from one principal across many services often indicates someone probing for permissions. A missing errorCode means the request was accepted. It does not tell you the change was correct, only that it was allowed.
readOnly, eventType, and eventID
readOnly is true for calls that do not change state, such as Describe*, List*, and Get*. Filtering on readOnly: false cuts the volume sharply when you look for changes. eventType is usually AwsApiCall, but you will also see AwsServiceEvent, AwsConsoleSignIn, and AwsCloudTrailInsight. eventID is a unique identifier you can use to cite one event or to remove duplicates.
Reading records from delivered log files
When a trail delivers to S3, each file is a gzip-compressed JSON document with a top-level Records array. This command extracts the key fields from one file, and it needs jq installed:
gunzip -c 123456789012_CloudTrail_us-east-1_20261120T0915Z_example.json.gz \
| jq '.Records[]
| {eventTime, eventName, eventSource,
who: (.userIdentity.arn // .userIdentity.invokedBy),
ip: .sourceIPAddress,
error: .errorCode}'The // operator falls back to invokedBy when arn is absent, which happens for AWSService identities. This one filter handles most types in a single pass.
Common mistakes
- Treating the session name as a person. An assumed-role ARN names a session, not a user. Trace the session back to the
AssumeRoleevent. - Comparing times in local time.
eventTimeis UTC. Convert before you build a timeline. - Searching for the CLI command name. Search for the API action, such as
PutObject, notcp. - Reading the absence of an error as success of intent. No
errorCodemeans the call was allowed, not that it was expected. - Trusting
userAgentandsourceIPAddressalone. Both are useful, but a caller can change a user agent, and a stolen key can be used from anywhere. - Ignoring failed calls. Denied requests show reconnaissance and misconfigured permissions.
Exercises
Exercise
In the example record, which fields show that the call was made by an IAM user through the AWS CLI, and what did the user do?
Show answer
userIdentity.type is IAMUser with userName alice, and userAgent is aws-cli/2.x. The eventName is StopLogging on cloudtrail.amazonaws.com, and requestParameters.name shows the target trail, org-audit-trail. Alice stopped logging on that trail.
Exercise
A record has userIdentity.type set to AssumedRole and an arn ending in assumed-role/DeployRole/build-4821. What is build-4821, and how would you find the person or system that created the session?
Show answer
build-4821 is the role session name, a label chosen by whoever called AssumeRole. It is not proof of identity. To find the origin, search for the AssumeRole (or AssumeRoleWithSAML or AssumeRoleWithWebIdentity) event that created the session, and read its userIdentity and sourceIPAddress. The sessionContext block in the later event also shows the session issuer, creation time, and MFA status.
Exercise
You see 300 events in ten minutes from one principal, all with errorCode set to AccessDenied across many services. What does that pattern suggest, and what two follow-up checks would you make?
Show answer
It suggests the principal is probing for permissions it does not have, which can mean compromised credentials or a misconfigured tool. Check the sourceIPAddress and userAgent for unusual values, and check whether any calls from the same principal succeeded, by searching for the same principal with no errorCode.