Get bucket size

Concepts

This page shows you how to get the size of your Cloud Storagebuckets.

Required roles

In order to get the required permissions for getting the size of aCloud Storage bucket, ask your administrator to grant you the StorageObject Viewer (roles/storage.objectViewer) role on the bucket. If you plan onusing the Google Cloud console, ask your administrator to grant you theMonitoring Viewer (roles/monitoring.viewer) role on the project that containsthe bucket instead.

These roles contain the permissions required to get the size of a bucket.To see the exact permissions that are required, expand theRequired permissions section:

Required permissions

  • storage.objects.list
    • This permission is only required for using the Google Cloud CLI toperform the instructions on this page.

To see the permissions associated withroles/monitoring.viewer,refer to theMonitoring Viewer documentation.

You might be able to get the required permission with otherpredefined roles orcustom roles. For instructions on granting roleson buckets, seeSet and manage IAM policies on buckets. For instructions ongranting roles on projects, seeManage access to projects.

Determine a bucket's size

Console

Note: Monitoring measures bucket size once a day and does notreport empty buckets. To measure bucket size at a given moment for anybucket, usegcloud storage instead.

To view the metrics for a monitored resource by using theMetrics Explorer, do the following:

  1. In the Google Cloud console, go to the Metrics explorer page:

    Go toMetrics explorer

    If you use the search bar to find this page, then select the result whose subheading isMonitoring.

  2. In the toolbar of the Google Cloud console, select your Google Cloud project. ForApp Hub configurations, select the App Hub host project or the app-enabled folder's management project.
  3. In theMetric element, expand theSelect a metric menu, enterTotal bytes (v2) in the filter bar, and then use the submenus to select a specific resource type and metric:
    1. In theActive resources menu, selectGCS Bucket.
    2. In theActive metric categories menu, selectStorage.
    3. In theActive metrics menu, selectTotal bytes (v2).
    4. ClickApply.
    The fully qualified name for this metric isstorage.googleapis.com/storage/v2/total_bytes.
  4. To add filters, which remove time series from the query results, use theFilter element.

  5. To combine time series, use the menus on theAggregation element. For example, to display the CPU utilization for your VMs, based on their zone, set the first menu toMean and the second menu tozone.

    All time series are displayed when the first menu of theAggregation element is set toUnaggregated. The default settings for theAggregation element are determined by the metric type you selected.

  6. For quota and other metrics that report one sample per day, do the following:
    1. In theDisplay pane, set theWidget type toStacked bar chart.
    2. Set the time period to at least one week.

You can also use the Metrics Explorer to measure other bucket metricssuch asstorage.googleapis.com/storage/object_count andstorage.googleapis.com/storage/v2/total_byte_seconds, which measure thedaily number of objects and the daily storage consumed, respectively. SeetheGoogle Cloud metrics documentation for a complete list ofavailable metrics andMetrics, time series, and resources for moreinformation about using the Metrics Explorer.

Command line

Caution: Thegcloud storage du command calculates the current spaceusage by making a series of object listing requests, which can take a longtime for large buckets. If the number of objects in your bucket ishundreds of thousands or more, or if you want to monitor your bucket sizeover time, use Monitoring instead, as described in theConsole tab.

Use thegcloud storage du command with a--summarize flag:

gcloud storage du gs://BUCKET_NAME --summarize

whereBUCKET_NAME is the name of the relevantbucket.

The response looks like the following example:

134620      gs://my-bucket

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

What's next

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

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.