S3 comes with some basic analytics for bucket size and number of objects, which are free and calculated automatically. However, if you want to view more detailed analytics for S3 requests, you’ll need to turn on request metrics.
In order to see request metrics, you’ll need to enable them for each bucket. These aren’t free like the default metrics — CloudWatch’s Paid Tier costs $0.30 per metric. Unfortunately, each S3 bucket can add up to 16 different request metrics, and they’re all on all the time. This brings the cost to $5 per bucket, potentially less depending on whether or not you use certain options.
To turn it on, head over to the Metrics tab for your bucket:
You’ll see the default metrics, and at the bottom, there’s a “View Additional Charts” button:
Click “Create Filter” to make a filter that will turn on request metrics.
You can limit this to a specific subset of items, or just select “This filter applies to all objects in the bucket.”
Once that’s done, request metrics will start being shipped to CloudWatch. It may take a little bit, so grab a coffee and come back to it.
Using Metrics in CloudWatch
Head over to the CloudWatch Management Console to get started.
You’ll need to create a new Dashboard, and add a widget to it. You can choose any kind of graph, but for simple request metrics, line charts generally work best.
For the metrics, select S3:
And then “Request Metrics Per Filter.”
You’ll then see a list of metrics available to you from the buckets you have request metrics enabled on. Two of the most useful are BytesDownloaded and BytesUploaded, which track raw data usage. You can graph them over time, and add this graph to your dashboard.
By default, the graph shows the average data usage. You’re probably interested in the total data usage, so under “Graphed Metrics,” you can change the statistic to “Sum,” which will total up all requests for the given period. This works best when set to a long period, like an hour or day.
Of course, like all CloudWatch metrics, you can set up automated alarms for when usage gets unexpectedly high, and also use those alarms for other events in your account.