how to query in cloud watch to get the details of Non current version bytes.

0

hello all, I want to know the data size of Non current version bytes for a specific bucket and folder. I have checked in cloud watch but I didn't get a correct filter and query. Requesting someone to provide a proper query to get the details of non current version in cloud watch.

1 Answer
0
Accepted Answer

You can refer to the S3 storage metrics provided by CloudWatch, like BucketSizeBytes and NumberOfObjects,but these metrics might not offer the granularity you want, as they are for the entire bucket and don't distinguish between current and non-current versions.However, you can use a combination of S3, S3 Inventory, and possibly Athena to get the details of non current versions. Here are the steps:

  1. Go to the S3 bucket, under the Management tab, set up an inventory which includes the IsLatest and Size fields and export S3 Inventory to a location.
  2. Once you have the inventory files in S3, you can set up an Athena table to query these files.
    • Using Athena, you can then query for all the objects where IsLatest is false (meaning they are non-current versions), sum up their sizes, and filter by the specific folder if needed.

Here is an example athena query:

SELECT SUM(size) as TotalNonCurrentVersionBytes
FROM s3_inventory_table
WHERE is_latest = 'false' AND key LIKE 'your-folder-name/%';

This would give you the total size of non-current version bytes for the specified folder.

AWS
Rumaisa
answered 9 months ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions