S3 access logs can be downloaded from the AWS Management Console or the AWS CLI. S3 access logs are not written in real time; they are created in batches that take a few hours to appear in your S3 logging bucket.
After a few hours, you can check your logging bucket to see whether the folder you had designated in your configuration file has appeared. Figure 7.1 shows that the folder was created after a short time, and AWS batched up the initial set of requests.
Figure 7.1: The logging folder for S3 access logs inside of our logging bucket
As you enter the folder that contains the S3 access logs, you will notice that unlike other batch groupings of logs that AWS gathers, these logs are not grouped in separate subfolders by month, day, and year. Instead, each log file’s name begins with a time-date stamp and ends with a semi-random value.
The logs themselves are in text format but have no extension added to them.
Consider the following example log:
3
0cd0fc55a0a1b1164bfd69733c5b1bedd043dd0ce88e77cb1b2cb9e6418a3e5 p
ackt-test-object [
11/Apr/2023:01:59:50 +0000] 123.456.78.90 arn:aws:iam::123456789101:user/packt 5GP5E0KH8855K76Y REST.GET.ACL – “GET /?acl HTTP/1.1” 200 – 556 – 14 – “-” “S3Console/0.4, aws-internal/3 aws-sdk-java/1.11.1030 Linux/5.4.238-155.347.amzn2int.x86_64 OpenJDK_64-Bit_Server_VM/25.362-b10 java/1.8.0_362 vendor/Oracle_Corporation cfg/retry-mode/standard” – uhbLAOkdZMQTHAfP/ixHjJtznBNWzDc4JcrOa0YTnqtBDJzmvUz2fViv2eL4IOZoadKJQet8rm0= SigV4 ECDHE-RSA-AES128-GCM-SHA256 AuthHeader packt-test-object.s3.us-east-1.amazonaws.com TLSv1.2 – –
The following are the fields in the order in which they appear in the preceding example:
Note
If you would like to know how to find the canonical user ID for your own AWS account, then you can find out more with the following URL: https://packt.link/Z0HUO.
The value in the example is as follows: 30cd0fc55a0a1b1164bfd69733c5b1bedd043dd0ce8 8e77cb1b2cb9e6418a3e5
The value in the example is as follows: packt-test-object
The value in the example is as follows: [11/Apr/2023:01:59:50 +0000]
The value in the example is as follows: 123.456.78.90
The value in the example is as follows: arn:aws:iam::123456789101:user/packt
The value in the example is as follows: 5GP5E0KH8855K76Y
The value in the example is as follows: REST.GET.ACL
The value in the example is as follows: –
The value in the example is as follows: “GET /?acl HTTP/1.1”
The value in the example is as follows: 200
The value in the example is as follows: –
The value in the example is as follows: 556
The value in the example is as follows: –
The value in the example is as follows: 14
The value in the example is as follows: –
The value in the example is as follows: “-“
The value in the example is as follows: “S3Console/0.4, aws-internal/3 aws-sdk-java/1.11.1030 Linux/5.4.238-155.347.amzn2int.x86_64 OpenJDK_64-Bit_Server_VM/25.362-b10 java/1.8.0_362 vendor/Oracle_Corporation cfg/retry-mode/standard”
The value in the example is as follows: –
The value in the example is as follows: uhbLAOkdZMQTHAfP/ixHjJtznBNWzDc 4JcrOa0YTnqtBDJzmvUz2fViv2eL4IOZoadKJQet8rm0=
The value in the example is as follows: SigV4
The value in the example is as follows: ECDHE-RSA-AES128-GCM-SHA256
The value in the example is as follows: AuthHeader
The value in the example is as follows: packt-test-object.s3.us-east-1.amazonaws.com
The value in the example is as follows: TLSv1.2
The value in the example is as follows: –
The value in the example is as follows: –
Now that you have seen what the S3 access logs look like, how to parse them manually, and where to retrieve them, take a look at another type of logging available from S3 object-level logging, discussed in the next section.