How to get S3 usage statistics
Virtuozzo Infrastructure allows you to sell Object Storage as a Service based on the AWS S3-compatible object storage.
This guide describes how to obtain S3 usage statistics for your customers.
You can find the object storage administrator API description in the Object Storage Orchestration API Reference.
Object storage usage
1. List all buckets with their usage by sending the GET service ostor-buckets request. The response returns a list of all buckets including:
- Usage at a specific moment of time (use
hmaxto get the maximum usage for the last hour) - An account associated with the bucket
2. Group buckets by account and aggregate usage for a specific hour using hmax. As a result, you will have storage usage per account for the specified hour.
Object storage operations and traffic usage
1. Obtain the list of usage objects for all buckets by sending the GET service ostor-usage request. The response returns a list of objects, where each object includes:
- Statistics for all buckets and non-bucket statistics (operations with buckets themselves) for a 30-minute period
- An account associated with the bucket or non-bucket statistics (operations with buckets themselves)
2. Request the last two objects (within one hour) or objects for the selected period.
3. Parse the usage and aggregate it per account. As a result, you will have operations and traffic usage per account for the specified hour.
4. Aggregate per hour statistics to get monthly usage.
Enjoy!