Display table of most recent 5 files in S3 buckets

I using Grafana OSS and am monitoring my S3 storage bucket sizes using the Cloudwatch datasource for Grafana. I would like to have a query which displays in table the most recent 5 files stored in each bucket. How can this be done in an easy and straightforward way?

From my searches, this looks like the approach I will take:

  • configure S3 Inventory for each bucket.
  • use Athena to define a table based on the inventory CSV
  • Create an Athena query to get the 5 most recent files for each bucket
  • add this Athena plugin and display the list in Grafana

Is there a better path to accomplish this that anyone can recommend?

Other options to explore:

  • enable S3 event notifications - process that event with Lambda → create CloudWatch metric, or print it in the suitable format to the log, so you can use CloudWatch log query
  • Maybe S3 access logs/Cloudtrail events have useful details, which can be queried