Skip to content

Instantly share code, notes, and snippets.

@lawliet89
Last active September 30, 2024 06:17
Show Gist options
  • Save lawliet89/f4687422afcc39ab19cad596975b6e90 to your computer and use it in GitHub Desktop.
Save lawliet89/f4687422afcc39ab19cad596975b6e90 to your computer and use it in GitHub Desktop.
Security Lake Athena Queries
-- Number of entries per bucket for the past 7 days
with dataset as (
SELECT json_extract_scalar(api.request.data, '$.bucketName') as bucketName, * FROM amazon_security_lake_table_ap_southeast_1_s3_data_2_0
WHERE accountid = '123459012'
)
SELECT bucketName, count(bucketName) as numberOfRecords FROM dataset
WHERE time_dt BETWEEN CURRENT_TIMESTAMP - INTERVAL '7' DAY AND CURRENT_TIMESTAMP
group by bucketName
ORDER BY numberOfRecords desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment