Getting bucket information

This page shows you how get information on the size and metadata of your Cloud Storage buckets. For an overview of buckets, read the Key Terms. To learn more about specific bucket properties, see Storage Classes and Bucket Locations.

Determining a bucket's size

To determine the size of a bucket:

Stackdriver

  1. Open the Stackdriver Metrics Explorer.

    Go to the Metrics Explorer

    If you haven't used Stackdriver previously, click on the Create a workspace button, and create a workspace for the project that contains your bucket.

  2. In the Find resource type and metric text box, enter storage.googleapis.com/storage/total_bytes.

    The associated chart displays the size of each bucket in the selected project.

You can also use the Metrics Explorer to measure other bucket metrics such as storage.googleapis.com/storage/object_count and storage.googleapis.com/storage/total_byte_seconds, which measure the daily number of objects and the daily storage consumed, respectively. See the Stackdriver metrics documentation for a complete list of available metrics and Metrics, time series, and resources for more information about using the Metrics Explorer.

gsutil

Use the gsutil du command with a -s flag:

gsutil du -s gs://[BUCKET_NAME]/

where [BUCKET_NAME] is the name of the desired bucket.

The response looks like the following example:

134620      gs://[BUCKET_NAME]

In this example, the size of the bucket is 134,620 bytes.

Displaying a bucket's location and default storage class

To display the geographic location and default storage class of a bucket:

Console

  1. Open the Cloud Storage browser in the Google Cloud Platform Console.
    Open the Cloud Storage browser
  2. In the bucket list, find the bucket you want to verify, and check its Location and Default storage class.

    Verify Multi-Regional Storage bucket class.

gsutil

Use the following gsutil ls command, replacing [VALUES_IN_BRACKETS] with the appropriate values:

gsutil ls -L -b gs://[BUCKET_NAME]/

The response looks like the following example:

gs://[BUCKET_NAME]/ :
  Storage class:         MULTI_REGIONAL
  Location constraint:   US
  ...

REST APIs

JSON API

  1. Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials.
  2. Use cURL to call the JSON API with a GET Bucket request that includes the desired fields, replacing [VALUES_IN_BRACKETS] with the appropriate values:
    curl -X GET -H "Authorization: Bearer [OAUTH2_TOKEN]" \
        "https://www.googleapis.com/storage/v1/b/[BUCKET_NAME]?fields=location%2CstorageClass"

The response looks like the following example:

{
  "location": "US",
  "storageClass": "MULTI_REGIONAL"
  "labels" : {
     ([YOUR_LABEL_KEY]): [YOUR_LABEL_VALUE]
   },
}

XML API

  1. Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials.
  2. Use cURL to call the XML API with a GET Bucket request that includes the desired query string parameter:
    • location for getting the location of the bucket.
    • storageClass for getting the default storage class of the bucket.
    Note that you can use only one such query parameter at a time with the XML API. For example, to get the location of a bucket, use the following command, replacing [VALUES_IN_BRACKETS] with the appropriate values:
    curl -X GET -H "Authorization: Bearer [OAUTH2_TOKEN]" \
        "https://storage.googleapis.com/[BUCKET_NAME]?location"

The response looks like the following example:

<LocationConstraint>US</LocationConstraint>

What's next

Oliko tästä sivusta apua? Kerro mielipiteesi

Palautteen aihe:

Tämä sivu
Cloud Storage
Tarvitsetko apua? Siirry tukisivullemme.