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 relevant 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 Standard Storage bucket class.

gsutil

Use the following gsutil ls command:

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

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

The response looks like the following example:

gs://[BUCKET_NAME]/ :
  Storage class:         STANDARD
  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:

    curl -X GET \
      -H "Authorization: Bearer [OAUTH2_TOKEN]" \
      "https://www.googleapis.com/storage/v1/b/[BUCKET_NAME]?fields=location%2CstorageClass"

    Where:

    • [OAUTH2_TOKEN] is the name of the access token you generated in Step 1.
    • [BUCKET_NAME] is the name of the relevant bucket. For example, my-bucket.

The response looks like the following example:

{
  "location": "US",
  "storageClass": "STANDARD"
}

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:

    curl -X GET \
      -H "Authorization: Bearer [OAUTH2_TOKEN]" \
      "https://storage.googleapis.com/[BUCKET_NAME]?[QUERY_PARAMETER]"

    Where:

    • [OAUTH2_TOKEN] is the name of the access token you generated in Step 1.
    • [BUCKET_NAME] is the name of the relevant bucket. For example, my-bucket.
    • [QUERY_PARAMETER] is:

      • location for getting the location of the bucket. The response looks like the following example: <LocationConstraint>US</LocationConstraint>.
      • storageClass for getting the default storage class of the bucket. The response looks like the following example: <StorageClass>NEARLINE</StorageClass>.

      You can use only one query parameter at a time with the XML API.

What's next

Bu sayfayı yararlı buldunuz mu? Lütfen görüşünüzü bildirin:

Şunun hakkında geri bildirim gönderin...

Yardım mı gerekiyor? Destek sayfamızı ziyaret edin.