Use get-bucket-stat to retrieve the total storage used and number of objects in a bucket. This command is useful for capacity monitoring, resource usage assessment, and cost optimization.
Prerequisites
Before you begin, ensure that you have:
An OSS bucket
The
oss:GetBucketStatpermission (Alibaba Cloud accounts have this permission by default; RAM users must be granted it explicitly — see Attach a custom policy to a RAM user)
Usage notes
Results may not reflect the current state. A delay of over one hour is possible between actual usage and the values displayed.
Syntax
ossutil api get-bucket-stat --bucket value [flags]| Parameter | Type | Description |
|---|---|---|
--bucket | string | The name of the bucket |
get-bucket-stat is implemented on top of the GetBucketStat API operation. This command also accepts global command-line options.
Examples
Get bucket statistics (default output)
ossutil api get-bucket-stat --bucket examplebucketReturns bucket-level statistics including total storage size and object count. For the full list of response fields, see GetBucketStat.
Get bucket statistics in JSON format
ossutil api get-bucket-stat --bucket examplebucket --output-format jsonReturns the same fields formatted as a JSON object. Use this format when parsing the output programmatically.
Get bucket statistics in YAML format
ossutil api get-bucket-stat --bucket examplebucket --output-format yamlReturns the same fields formatted as YAML. Use this format for configuration workflows or when integrating with YAML-based tooling.