Query logs with Athena
Using Athena with CloudTrail logs is even easier than server access logs. With server access logs, you had to go to the Athena console to create a database and table, but with CloudTrail logging, Athena will automatically create a table for you.
To use Athena with CloudTrail logs, simply go to the CloudTrail event history and select Run advanced queries in Amazon Athena.
- Go to CloudTrail console. On left panel, select Event history, select Create Athena table.

- for Storage location, select bucket aws-cloud-trail-logs-workshop which we are using to store logs then select Create table.

- Confirm Athena table cloudtrail_logs_aws_cloudtrail_logs_workshop created.

- Find select service Athena, then select Launch query editor.

- If this is the first time you use Athena, select Edit settings, if not, skip to step 10.

- Click Browse S3.

- Select 1 bucket to store query’s result, here we choose bucket logging-workshop-destination.

- Check and click Save.

- Check and click Editor to return.

- Copy the query into the editor, make sure you are using the right table.This query will filter operation GetObject whihc have eventsource is s3.amazonaws.com. select Run.
SELECT *
FROM cloudtrail_logs_aws_cloudtrail_logs_workshop
WHERE
eventsource = 's3.amazonaws.com' AND
eventname in ('GetObject')

- Check the result below.

- Finally, run this query to drop the table.
DROP TABLE `cloudtrail_logs_aws_cloudtrail_logs_workshop`
