All Products
Search
Document Center

Object Storage Service:Query the storage usage and number of objects in a bucket

Last Updated:Mar 20, 2026

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:GetBucketStat permission (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]
ParameterTypeDescription
--bucketstringThe name of the bucket
Note

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 examplebucket

Returns 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 json

Returns 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 yaml

Returns the same fields formatted as YAML. Use this format for configuration workflows or when integrating with YAML-based tooling.