Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Example Security Lake queries for CloudTrail data

Focus mode
Example Security Lake queries for CloudTrail data - Amazon Security Lake

AWS CloudTrail tracks user activity and API usage in AWS services. Subscribers can query CloudTrail data to learn the following types of information:

Here are some example queries of CloudTrail data for AWS source version 1:

Unauthorized attempts against AWS services in the last 7 days

SELECT time, api.service.name, api.operation, api.response.error, api.response.message, unmapped['responseElements'], cloud.region, actor.user.uuid, src_endpoint.ip, http_request.user_agent FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_cloud_trail_mgmt_1_0 WHERE eventDay BETWEEN cast(date_format(current_timestamp - INTERVAL '7' day, '%Y%m%d%H') as varchar) and cast(date_format(current_timestamp - INTERVAL '0' day, '%Y%m%d%H') as varchar) AND api.response.error in ( 'Client.UnauthorizedOperation', 'Client.InvalidPermission.NotFound', 'Client.OperationNotPermitted', 'AccessDenied') ORDER BY time desc LIMIT 25

List of all CloudTrail activity from source IP 192.0.2.1 in the last 7 days

SELECT api.request.uid, time, api.service.name, api.operation, cloud.region, actor.user.uuid, src_endpoint.ip, http_request.user_agent FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_cloud_trail_mgmt_1_0 WHERE eventDay BETWEEN cast(date_format(current_timestamp - INTERVAL '7' day, '%Y%m%d%H') as varchar) and cast(date_format(current_timestamp - INTERVAL '0' day, '%Y%m%d%H') as varchar) AND src_endpoint.ip = '127.0.0.1.' ORDER BY time desc LIMIT 25

List of all IAM activity in the last 7 days

SELECT * FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_cloud_trail_mgmt_1_0 WHERE eventDay BETWEEN cast(date_format(current_timestamp - INTERVAL '7' day, '%Y%m%d%H') as varchar) and cast(date_format(current_timestamp - INTERVAL '0' day, '%Y%m%d%H') as varchar) AND api.service.name = 'iam.amazonaws.com' ORDER BY time desc LIMIT 25

Instances where the credential AIDACKCEVSQ6C2EXAMPLE was used in the last 7 days

SELECT actor.user.uid, actor.user.uuid, actor.user.account_uid, cloud.region FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_cloud_trail_mgmt_1_0 WHERE eventDay BETWEEN cast(date_format(current_timestamp - INTERVAL '7' day, '%Y%m%d%H') as varchar) and cast(date_format(current_timestamp - INTERVAL '0' day, '%Y%m%d%H') as varchar) AND actor.user.credential_uid = 'AIDACKCEVSQ6C2EXAMPLE' LIMIT 25

List of failed CloudTrail records in the last 7 days

SELECT actor.user.uid, actor.user.uuid, actor.user.account_uid, cloud.region FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_cloud_trail_mgmt_1_0 WHERE status='failed' and eventDay BETWEEN cast(date_format(current_timestamp - INTERVAL '7' day, '%Y%m%d%H') as varchar) and cast(date_format(current_timestamp - INTERVAL '0' day, '%Y%m%d%H') as varchar) ORDER BY time DESC LIMIT 25
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.