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:
Monitoring
To use Metrics Explorer to view the metrics for a monitored resource, follow these steps:
- In the Google Cloud Console, go to the Monitoring page.
If you have never used Cloud Monitoring, then on your first access of Monitoring in the Google Cloud Console, a Workspace is automatically created and your project is associated with that Workspace. Otherwise, if your project isn't associated with a Workspace, then a dialog appears and you can either create a Workspace or add your project to an existing Workspace. We recommend that you create a Workspace. After you make your selection, click Add.
- In the Monitoring navigation pane, click
Metrics Explorer.
- Ensure that Metric is the selected tab.
- In the Find resource type and metric field, select from the menu or
enter the name for the resource and metric. Use the following information to complete the
fields:
- For the Resource, select or enter gcs_bucket.
- For the Metric, select or enter Total bytes.
- To modify how the data is displayed, use the Filter, Group By, and Aggregator menus. For example, you can group by resource or metric labels. For more information, see Selecting metrics.
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 Google Cloud 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://my-bucket
In this example, the size of the bucket named my-bucket
is 134,620 bytes.
Displaying a bucket's metadata
To display the metadata associated with a bucket:
Console
- Open the Cloud Storage browser in the Google Cloud Console.
Open the Cloud Storage browser (Optional): You can limit the columns displayed in the Cloud Console bucket list by clicking the Column display options menu (
).
In the bucket list, find the bucket you want to verify, and check its column headers for the metadata you want to view.
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://my-bucket/ : Storage class: STANDARD Location constraint: US ...
Code samples
For more information, see the
Cloud Storage C++ API reference documentation.
For more information, see the
Cloud Storage C# API reference documentation.
For more information, see the
Cloud Storage Go API reference documentation.
For more information, see the
Cloud Storage Java API reference documentation.
For more information, see the
Cloud Storage Node.js API reference documentation.
For more information, see the
Cloud Storage PHP API reference documentation.
For more information, see the
Cloud Storage Python API reference documentation.
For more information, see the
Cloud Storage Ruby API reference documentation.
C++
C#
Go
Java
Node.js
PHP
Python
Ruby
REST APIs
JSON API
- Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials.
Use
cURL
to call the JSON API with aGET
Bucket request:curl -X GET \ -H "Authorization: Bearer OAUTH2_TOKEN" \ "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME"
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
.
Narrow down the results to your desired fields using query parameters:
curl -X GET \ -H "Authorization: Bearer OAUTH2_TOKEN" \ "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME?fields=FIELD1%2CFIELD2"
Where
FIELD#
is a bucket property you want to include in the result. For example,location
andstorageClass
.
The response looks like the following example:
{ "location": "US", "storageClass": "STANDARD" }
XML API
- Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials.
Use
cURL
to call the XML API with aGET
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 the metadata field you want to return. For example,location
for getting the location of the bucket. You can only use one query parameter at a time with the XML API.
The response looks like the following example:
<LocationConstraint>US</LocationConstraint>
.
What's next
- List the objects in your bucket.
- Change the default storage class for your bucket.
- Add, remove, and view the labels on your bucket.
- View and edit the metadata of objects in your bucket.
- Learn more about monitoring your resources in Monitoring.
Try it for yourself
If you're new to Google Cloud, create an account to evaluate how Cloud Storage performs in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
Try Cloud Storage free