CloudTrail log filtering before ingestion means removing low-value CloudTrail events before your SIEM indexes and bills them. We recommend two layers: CloudTrail advanced event selectors stop collecting data events you don’t use, and a pipeline such as NXLog Agent filters only the SIEM-bound copy. The full trail stays in Amazon S3 for audits and investigations.
If your SIEM bill jumps every time a team turns on S3 data events, you need to know what you can drop without losing a detection. This article shows where each filter belongs, which events must reach your SIEM no matter what, and how NXLog Agent filters the copy that goes to Splunk.
Key takeaways
-
Filter the copy your SIEM ingests, and keep the full trail in Amazon S3.
-
Trails can filter management events only by read or write type, plus an exclusion for KMS or RDS Data API events, so event-level decisions belong in your pipeline.
-
Let protections override every drop rule: errors, root activity, sign-ins, and credential reads pass whichever rule matched.
-
Measure before and after. We haven’t found a published benchmark that tells you what share of CloudTrail is safe to drop.
What is CloudTrail log filtering before ingestion?
It’s deciding which CloudTrail events your SIEM needs to see before it indexes them. There are two ways to do it, and the difference decides whether you can still investigate later:
- Don’t record
-
Advanced event selectors change what a trail logs. CloudTrail delivers only the events that match your trail settings to both your S3 bucket and your CloudWatch Logs log group, so a selector removes events from the record too.
- Don’t forward
-
A pipeline drops or tags events on their way to the SIEM. The trail’s S3 copy keeps everything, and log file integrity validation, once you enable it, shows whether anyone changed or deleted a file after delivery.
You can filter in three places: at the source with selectors, on the AWS delivery path with CloudWatch Logs subscription filters or EventBridge rules, and in a pipeline such as NXLog Agent. This post uses the source and the pipeline, and sends the result to Splunk.
Is CloudTrail free? Where the volume and the cost come from
Partly. CloudTrail gives you 90 days of management events in Event history and one trail copy of management events at no charge. Data events, extra copies, and every byte you send downstream cost money.
| What you use | Price as of November 2026 |
|---|---|
Event history (last 90 days of management events) |
No charge |
First trail copy of management events |
No charge |
Additional copies of management events |
$2.00 per 100,000 events |
Data events |
$0.10 per 100,000 events |
Network activity events |
$0.10 per 100,000 events |
Data event aggregation |
$0.03 per 100,000 events analyzed, plus data event charges |
The path in this article adds two more meters:
- CloudWatch Logs ingestion
-
You pay to ingest everything the trail sends to the log group, $0.50 per GB in AWS’s US East (N. Virginia) pricing examples. Subscription filters, which this design needs, aren’t available in the Essentials class (formerly Infrequent Access), and you can’t change a log group’s class later.
- Your SIEM
-
Splunk’s pricing models include ingest, workload, and activity-based pricing. On ingest pricing, every event you drop is license you don’t use. On the other models, fewer events still means less to index, store, and search.
AWS’s own documentation points to three common sources of volume:
- KMS cryptographic calls
-
Encrypt, Decrypt, and GenerateDataKey typically make up more than 99% of KMS events.
- Data events
-
S3 object and Lambda activity can generate thousands of events per minute.
- Read-only management calls
-
Some, such as KMS DescribeKey and IAM GetRole, occur at a much higher volume than typical change events.
If you size the problem from S3, AWS’s pricing example puts unzipped CloudTrail data at typically 5 to 10 times its gzip size. None of these figures tells you your own mix, which is what the next step measures.
How do you find your noisiest CloudTrail events?
Query the CloudWatch Logs log group your trail already feeds (if it only writes to S3, run the same counts in Athena), and rank events by size as well as count. A few large events can cost more than many small ones.
Start with the baseline.
CloudWatch Logs publishes IncomingBytes per log group, measured in uncompressed bytes, and its daily sum is your unfiltered starting point.
Then find the top event types with CloudWatch Logs Insights, which discovers CloudTrail’s JSON fields for you:
fields messageSize(@message) as msgBytes
| stats count(*) as events, sum(msgBytes) as bytes by eventSource, eventName, readOnly
| sort bytes desc
| limit 25
Logs Insights extracts up to 200 fields per event, so large records can show readOnly as empty; treat a large empty group as a prompt to check those events in Athena.
The messageSize() function returns each event’s size in bytes.
To see the callers behind successful calls:
fields messageSize(@message) as msgBytes, coalesce(userIdentity.arn, "-") as arn, coalesce(userIdentity.invokedBy, "-") as invokedBy
| filter not ispresent(errorCode)
| stats count(*) as events, sum(msgBytes) as bytes by readOnly, userIdentity.type, arn, invokedBy
| sort bytes desc
| limit 25
Logs Insights bills by data scanned, so start with a 24-hour window. For data events you keep only in S3, count the same fields in Athena. The result is a shortlist of event types and callers. Give each candidate rule a named owner who signs off before you drop anything.
Layer 1: control what CloudTrail records
Use advanced event selectors for one job: stop recording data events nobody needs anywhere. They’re coarse for management events, and they change the record itself, so leave event-level decisions to Layer 2.
| Event category | Fields a trail can filter on |
|---|---|
Management |
|
Data |
|
Network activity |
|
Selectors don’t accept wildcards, and within a selector, any matching NotEquals, NotStartsWith, or NotEndsWith condition blocks an event, whatever the select conditions say.
Split data events by destination
Put the data events your detections use into the trail that feeds CloudWatch Logs, and the ones you keep only for investigations into a second trail that writes to S3 alone. AWS documents this kind of split, with separate trails delivering management and data events. For example, the feed trail keeps every management event plus every write on your sensitive buckets, and the archive trail records GetObject calls on the same buckets.
One compliance catch: under CIS v3.0.0 and v5.0.0, Security Hub CSPM controls S3.22 and S3.23 pass only when a multi-Region trail logs S3 object writes for all buckets (S3.22) and a multi-Region trail logs S3 object reads for all buckets (S3.23). If you report against those standards, make the archive trail multi-Region and have it record every S3 read and write. CloudTrail then bills writes on the sensitive buckets on both trails. That includes reads and writes on the trail’s own log bucket and on any bucket Athena or Splunk reads, so measure that volume before you switch it on.
Important notes on this architecture:
-
A
readOnlyfalse condition catches every write, including copies and multipart uploads, which S3 logs under their own event names such as CopyObject and CompleteMultipartUpload. A list of PutObject and DeleteObject alone would miss them. -
The archive trail’s reads don’t reach Splunk through this pipeline, including denied ones. If a Splunk Add-on for AWS input already reads CloudTrail from S3, point the archive trail at a bucket or prefix that input doesn’t read. Trails can’t filter data events by error code. If you alert on failed object reads, also record GetObject on those buckets in the feed trail. Then add an NXLog Agent rule above the protections that tags those GetObject calls, and add the tag to the
drop()list and to the dry-run searches. TheerrorCodeprotection still forwards the failures. CloudTrail then bills those GetObject events on both trails, and CloudWatch Logs ingests every one, so weigh that cost against the alert. -
Leave management events off the archive trail. A second copy costs $2.00 per 100,000 events. The same goes for the feed trail: if the account already has a trail that records management events, such as an organization trail, use that trail as the feed trail, or the new one becomes a paid second copy. If that trail already sends to a Standard-class log group, add your subscription filter there (a log group takes up to five) instead of creating a new group. If the trail writes to an Essentials-class group, which supports neither subscription filters nor metric filters, point it at a new Standard-class group. If you re-point a trail away from a Standard-class group, its events stop reaching that group’s metric filters and alarms, so recreate them on the new group first. Keep the log group and the Lambda function in the account that owns the trail (for an organization trail, the management account) and in the trail’s home Region, because CloudTrail only sends to a log group in the trail’s Region.
-
A trail uses basic or advanced selectors, not both. Applying advanced selectors overwrites the basic ones.
Keep KMS events in the trail
Encrypt, Decrypt, and GenerateDataKey dominate KMS volume, so excluding kms.amazonaws.com looks tempting. Don’t do it at the source:
-
The first trail copy of management events is free. If the feed trail is that copy, excluding KMS saves nothing in CloudTrail itself.
-
Under the CIS v1.2.0 and v1.4.0 standards, Security Hub CSPM control CloudWatch.7, which checks for a metric filter and alarm on customer managed keys being disabled or scheduled for deletion, fails when a trail’s event selectors exclude kms.amazonaws.com. In CIS v5.0.0 it’s a manual check, but the events it looks for disappear all the same.
-
AWS’s KMS guide warns that excluding KMS events can obscure actions that use your keys.
CloudWatch Logs still ingests every KMS read before NXLog Agent drops it, so use the query above to see what that costs. Then drop the reads in Layer 2, where failures and human callers can still pass.
Layer 2: filter the Splunk-bound copy with NXLog Agent
NXLog Agent receives every event the feed trail records, applies your protections, drops or tags the noise, and forwards the rest to Splunk.
The flow builds on NXLog’s documented AWS pattern, where CloudWatch Logs triggers a Lambda function that pushes events to an NXLog Agent HTTP(s) input module instance.
Here the trail writes to a Standard-class log group with short retention.
Unlike the sample function in that guide, which posts each decoded batch as a single request, your function should unpack the logEvents array and post each CloudTrail event over HTTPS as its own request.
Three details shape that delivery path:
- Large events skip CloudWatch Logs
-
CloudTrail doesn’t send events larger than 256 KB to CloudWatch Logs. Event version 1.05 and later caps events at that size, so this affects only services on earlier versions, and S3 still records the events.
- One request per event
-
NXLog Agent’s HTTP(s) input module reads each request body as one event and answers every valid request with HTTP 200. Your Lambda function must therefore post each CloudTrail event as its own request and raise an error on any other response. An empty subscription filter pattern forwards everything, so every keep-or-drop decision lives in one place you can review and test.
- Retries can duplicate events
-
CloudWatch Logs invokes Lambda asynchronously. When the function returns an error, Lambda retries it two more times by default before it discards the event, so configure a failed-event destination. With the defaults, an NXLog Agent outage longer than about three minutes sends events there instead of to Splunk, so plan how you replay them. A retry reruns the whole batch of log events. Lambda can also deliver the same event more than once even without an error, so deduplicate on
eventIDin searches that count.
The decisions happen in the Exec block of the HTTP(s) input module instance.
Your configuration also needs the JSON extension module with Flatten set to TRUE, an HTTP(s) input module instance that requires client certificates for mutual TLS, and an HTTP(s) output module instance to Splunk HEC’s /services/collector/event endpoint.
Set up the output as in NXLog’s Splunk integration guide, with the following changes.
Instead of serializing every field with to_json(), the output wraps the untouched $raw_event in the HEC envelope.
It sets the index, the sourcetype to aws:cloudtrail, and the time from eventTime converted to epoch seconds.
It also puts nx_rule under fields so Splunk indexes it.
Check your JSON extension module settings, in particular DetectNestedJSON and UnFlatten in the JSON extension module reference, so the event goes out as the original string rather than re-serialized JSON.
Also make sure the guide’s Rewrite extension module Keep list doesn’t strip index or the field that carries nx_rule.
Set the HTTP(s) input module’s ListenAddr to an address the Lambda function can reach (the example in NXLog’s AWS guide binds 127.0.0.1).
Make sure the HEC token’s allowed indexes include the index you set and that the token doesn’t require indexer acknowledgment.
The Lambda function needs the following:
-
A network path to the agent’s listener, for example as a VPC-attached function.
-
The client certificate and key to present.
-
One kept-alive connection per invocation, with a Content-Length header on each request.
-
A timeout long enough to post a full batch (the 3-second default is too short).
-
A check that skips payloads whose
messageTypeis CONTROL_MESSAGE.
FILTER_MODE is a define that starts as dryrun:
parse_json();
$nx_rule = 'default';
if $eventSource == 'kms.amazonaws.com' and $readOnly == TRUE (1)
{
if $userIdentity.type == 'AWSService' $nx_rule = 'kms_service_read';
}
if $readOnly == TRUE and
$sourceIPAddress IN ('203.0.113.10', '203.0.113.11') (2)
{
if $userIdentity.arn =~
/^arn:aws:sts::\d{12}:assumed-role\/(?:cspm-scanner|inventory-reader)\//
{
$nx_rule = 'automation_read';
}
}
if defined($errorCode) $nx_rule = 'protected'; (3)
if $userIdentity.type == 'Root' $nx_rule = 'protected';
if $eventName IN ('ConsoleLogin', 'GetPasswordData', 'GetFederationToken')
{
$nx_rule = 'protected';
}
if $eventName IN ('GetSecretValue', 'BatchGetSecretValue', 'GetParameter',
'GetParameters', 'GetParametersByPath', 'GetParameterHistory')
{
$nx_rule = 'protected';
}
if '%FILTER_MODE%' == 'enforce' and
$nx_rule IN ('kms_service_read', 'automation_read')
{
drop();
}
| 1 | Rule 1: KMS reads made by AWS service principals. |
| 2 | Rule 2: reads by approved scanners from their known IPs (errors are protected below). |
| 3 | Protections run last, so they override the rules above. |
How the decisions work:
- Rules tag, protections override
-
Each rule only sets the
nx_rulefield. The protections run last, so an error, root activity, a sign-in, or a credential read ends up tagged protected. - A missing field can’t trigger a drop
-
In NXLog Agent, comparing an undefined field returns an unknown value, which evaluates to
FALSE, so a rule can’t fire on a field it can’t see. - Rule 1 matches only service principals
-
It catches KMS reads where an AWS service is itself the caller. Many service-driven calls, such as S3 encrypting with SSE-KMS, carry the calling role’s identity instead, so Rule 1 leaves those alone. Add
| filter eventSource = "kms.amazonaws.com"before the stats line of the caller query to see how much of your KMS volume Rule 1 covers. - Rule 2 is narrow on purpose
-
It needs a read-only call, an approved role, and a known source IP. If someone steals the scanner’s credentials, their writes, errors, and calls from other addresses still reach Splunk.
- Splunk gets the original record
-
Set up as described above, the output sends the untouched CloudTrail JSON with the aws:cloudtrail sourcetype and
nx_ruleas an indexed field. With the Splunk Add-on for AWS installed on your search heads, that sourcetype maps to the CIM Change and Authentication data models. WithPersistLogqueueandSyncLogqueueenabled, NXLog Agent removes an event from its queue only after delivery succeeds, so queued events survive a crash. SizeLogqueueSizefor the Splunk outage you want to ride out: once the queue fills, flow control stops the HTTP(s) input module from accepting events, and the Lambda retry clock starts.
Dry run, then enforce
In dryrun mode, every event reaches Splunk with its nx_rule value as an indexed field.
With the Splunk Add-on for AWS on your search heads to extract the JSON fields, see what enforcement would remove:
index=<your_nxlog_index> sourcetype=aws:cloudtrail (nx_rule::kms_service_read OR nx_rule::automation_read)
| fillnull value="-" userIdentity.arn userIdentity.invokedBy
| stats count by nx_rule, eventSource, eventName, userIdentity.arn, userIdentity.invokedBy
Then rerun each CloudTrail detection over the same window against NXLog Agent’s index, once as is and once with NOT (nx_rule::kms_service_read OR nx_rule::automation_read) added.
If any detection returns fewer results, fix the rule first.
For detections that run on accelerated CIM data models, which can’t filter on nx_rule, compare the raw-search version of each detection instead.
If CloudTrail also reaches Splunk through another input, such as the Splunk Add-on for AWS reading from S3, send NXLog Agent’s copy to a separate index for the dry run, or the comparison and the reconciliation below won’t mean anything.
Keep that index out of your CIM data models until you switch: unless you constrain them in the CIM setup, data models search every index, so they would count both copies.
Both copies count against your Splunk license during the dry run, so plan for that volume or run the dry run on a subset of accounts.
When you switch to enforce, either point NXLog Agent’s output at your production index or add its index to your detections and the CIM data model index macros, then retire the old input.
If the dry run tags no events at all, check that your JSON extension module version stores readOnly as a boolean, which the rules compare against TRUE.
Run the dry run for at least seven days so weekly jobs show up, then set FILTER_MODE to enforce and restart NXLog Agent.
Run it across collectors with NXLog Pipeline Manager
With more than one collector, for example one per AWS account or per organization, NXLog Pipeline Manager rolls out the same rules as one shared configuration. You can also use role-based access control to limit who edits them. Its data flow visualization shows how much data enters each agent through its inputs and leaves through its outputs, so you can compare the two and confirm the drop.
Which CloudTrail events should you never filter?
Anything a CIS AWS Foundations Benchmark control watches, plus the calls attackers use to blind your logging. AWS Security Hub CSPM spells out the CIS metric filters event by event:
| Control | What it watches | CloudTrail events it matches |
|---|---|---|
CloudWatch.1 |
Root user activity |
Calls where |
CloudWatch.2 |
Unauthorized API calls |
|
CloudWatch.3 |
Console sign-in without MFA |
Successful ConsoleLogin by an IAM user without MFA |
CloudWatch.4 |
IAM policy changes |
Create, delete, put, attach, and detach calls on IAM policies |
CloudWatch.5 |
CloudTrail configuration changes |
CreateTrail, UpdateTrail, DeleteTrail, StartLogging, StopLogging |
CloudWatch.6 |
Console authentication failures |
ConsoleLogin with "Failed authentication" |
CloudWatch.7 |
KMS keys disabled or scheduled for deletion |
DisableKey, ScheduleKeyDeletion |
CloudWatch.8 |
S3 bucket policy changes |
PutBucketAcl, plus put and delete calls on bucket policies, CORS, lifecycle, and replication |
CloudWatch.9 |
AWS Config changes |
StopConfigurationRecorder, DeleteDeliveryChannel, PutDeliveryChannel, PutConfigurationRecorder |
CloudWatch.10 |
Security group changes |
Authorize and revoke ingress or egress, CreateSecurityGroup, DeleteSecurityGroup |
CloudWatch.11 |
Network ACL changes |
Create, delete, and replace calls on network ACLs and their entries |
CloudWatch.12 |
Network gateway changes |
Customer gateway create and delete calls, and internet gateway create, delete, attach, and detach calls |
CloudWatch.13 |
Route table changes |
Route and route table create, replace, delete, and disassociate calls |
CloudWatch.14 |
VPC changes |
CreateVpc, DeleteVpc, ModifyVpcAttribute, and VPC peering and ClassicLink calls |
AWS recommends CIS v5.0.0, which lists these as manual checks, but the events matter either way.
The NXLog Agent rules above pass all of these events. They drop only successful, read-only calls by non-root identities, while every pattern in the table targets a write, an error, a sign-in, or root activity. Four more groups belong on your list:
- Calls that switch logging off
-
MITRE ATT&CK tracks this as T1685.002, Disable or Modify Cloud Log, which replaced T1562.008 in April 2026. CloudWatch.5 covers the StopLogging and DeleteTrail calls its detection strategy flags.
- Calls that narrow logging
-
Stratus Red Team blinds a trail by changing its event selectors, so the feature Layer 1 relies on is an attacker’s tool too. Alert on PutEventSelectors and limit who can call it, for example with a service control policy.
- Reads that steal credentials
-
Stratus Red Team’s AWS techniques emulate retrieving EC2 password data, Secrets Manager secrets, and decrypted SSM parameters, plus generating credentials with GetFederationToken, which Stratus files under persistence. Most of these calls are read-only, so the rules protect them by name.
- Changes to the pipeline itself
-
Your subscription filter and forwarder function are now part of your logging. Alert on DeleteSubscriptionFilter, PutSubscriptionFilter, DeleteLogGroup and PutRetentionPolicy on the feed log group, and on any change to the Lambda function, including its code, configuration, permissions, concurrency, and asynchronous invocation settings. CloudTrail records Lambda calls with version suffixes, such as UpdateFunctionCode20150331v2 and PutFunctionConcurrency20171031, so match lambda.amazonaws.com events on
requestParameters.functionNamerather than on exact event names. Match both the bare name and the ARN form, because callers can pass either. Don’t rely on this pipeline alone to deliver those alerts: once the filter, the log group, or the function changes, the events that record it may never reach Splunk. Match them, and StopLogging, DeleteTrail, UpdateTrail, and PutEventSelectors on the feed trail, with an EventBridge rule in the trail’s home Region that notifies through a channel outside this pipeline, such as an SNS topic. EventBridge receives these events only while a trail is logging, so treat a StopLogging or DeleteTrail alert as urgent. Also alert in Splunk when NXLog Agent’s index stops receiving events.
How do you prove the filter didn’t break detections?
Check three things: the counts reconcile, the protected events arrive, and your detections return the same results with and without the dropped events.
- Reconcile the counts
-
Compare the log group’s
IncomingLogEventsand the subscription filter’sForwardedLogEvents(CloudWatch Logs metrics) with what NXLog Agent received and dropped. Since version 6.6, NXLog Agent’sevt-dropcounter includes every event removed bydrop(). From version 6.9, the Internal Metrics input module reports it asevt_drop. Over the same time window, received minus dropped should match what Splunk indexed, give or take Lambda retries, events sent to the failed-event destination, and events Lambda discards when the function can’t keep up with its queue. - Detonate in a sandbox account that your feed trail covers
-
For example, use a member account under your organization trail, or a test account with its own feed trail, Lambda function, and NXLog Agent. Run a few Stratus Red Team techniques, such as stopping a trail, changing its event selectors, and retrieving Secrets Manager secrets. Every resulting event should appear in Splunk, and none should carry a drop rule’s tag.
- Review on a schedule
-
Rerun the Logs Insights shortlist every quarter, and whenever AWS adds a new kind of event. A rule that was safe last quarter can hide something new.
Where should you filter CloudTrail?
Use selectors for events nobody needs, and a pipeline for events only your SIEM can skip.
| Filter point | What it can filter on | Changes the S3 record? | Extra cost | Best for |
|---|---|---|---|---|
Management events: read or write type, plus a KMS or RDS Data API exclusion. Data events: event name, resource ARN, identity, and more |
Yes |
None. Narrower data event selectors lower data event charges |
Data events nobody needs anywhere |
|
Nothing; it adds 5-minute summaries alongside the data events |
No (adds summaries) |
$0.03 per 100,000 events analyzed, on top of data event charges |
Trends on high-volume data events |
|
A filter pattern, with up to five subscription filters per log group |
No |
CloudWatch Logs ingests everything the trail sends, filtered or not |
Coarse routing before Lambda |
|
Event patterns. Read-only management events need an opt-in |
No |
Depends on the target |
Real-time response to a few event types |
|
Any field or combination, with protections, tags, and a dry run |
No |
Compute for the agent, plus CloudWatch Logs ingestion and Lambda on the delivery path in this post |
Event-level decisions on the SIEM copy |
Filter the copy, keep the record
Filter CloudTrail in two layers and keep the record complete. Selectors stop data events nobody needs, NXLog Agent decides event by event what Splunk needs, and the trail in S3 keeps everything for audits and investigations.
Test in your lab first. Run your rules against a test AWS account and a test Splunk index before production. Check that your Lambda function’s HTTPS client works with the HTTP(s) input module, which has a partial HTTP/1.1 implementation designed for NXLog’s own HTTP(s) output module.
Want to see what your own CloudTrail volume looks like after filtering? Start with the Free plan and run the dry run on your own data.
FAQ
- Can I filter CloudTrail management events by event name?
-
Not on a trail. Trails filter management events only by read or write type, and can exclude KMS or RDS Data API events. CloudTrail Lake event data stores add
eventNameanduserIdentity.arn, and a pipeline such as NXLog Agent can filter on any field. - Does excluding events from a trail affect GuardDuty?
-
No. GuardDuty reads management events through its own independent stream, and AWS states that your CloudTrail configuration doesn’t affect how GuardDuty consumes them. S3 Protection, which analyzes S3 data events, doesn’t need S3 data event logging in your trail either.
- Should I drop read-only CloudTrail events?
-
Not as a blanket rule. Read-only calls include discovery and credential theft, such as GetSecretValue. Drop read-only calls only from known automation and known addresses, and protect credential reads by name.
- Does filtering CloudTrail before ingestion break compliance?
-
Not when you filter the SIEM copy and keep the trail. The trail’s S3 copy keeps every event it records for as long as your bucket’s lifecycle rules allow. Log file integrity validation, once you enable it, shows whether anyone changed or deleted a file after delivery. Check your framework’s retention rules, and keep KMS events in the trail so the key events your CIS checks look for are still recorded. If you follow CIS v3.0.0 or v5.0.0, keep multi-Region trail coverage of S3 object reads and writes for all buckets.