13

I am using Google Cloud Storage. Where can I determine my total space used? I can't seem to find where in the dashboard it tells you the total usage in megabytes or gigabytes.

Screenshot of Dashboard

Misha Brukman
  • 12,938
  • 4
  • 61
  • 78
speedplane
  • 15,673
  • 16
  • 86
  • 138

4 Answers4

8

Do you have the gsutil command line utility installed? If so, you can use the gsutil du command to see the space used for objects and buckets.

E.g., gsutil du -s gs://my-bucket-name/ should work.

https://cloud.google.com/storage/docs/gsutil/commands/du

nonbeing
  • 6,907
  • 6
  • 36
  • 46
saturnism
  • 332
  • 1
  • 6
  • 5
    Eeks... there's no way to see it in a dashboard? Would be nice if non-programmers could see how much space we're using. – speedplane Oct 12 '15 at 16:43
  • @speedplane – thanks for the feedback, I passed it on to the team. In the mean time, you can also click on the [Google Cloud Shell](https://cloud.google.com/cloud-shell/#how_do_i_get_started) button in the console to run the command, so you don't have to install `gcloud` locally. – Misha Brukman Oct 12 '15 at 17:13
  • It would be really useful to be able to see the amount of space being used on the dashboard - I was a bit surprised it wasn't possible to add it to the dashboard already – Simon Oct 29 '16 at 19:58
  • This is not practical for large buckets. The other answer, though it takes more steps, is more useful for buckets with a lot of files. – forresthopkinsa May 31 '21 at 22:21
  • The ability to see the total storage in the dashboard is still missing. – talonx Feb 03 '22 at 10:43
8

What you need is now available through Stackdriver Metrics Explorer, go to Stackdriver -> Resources -> Metrics Explorer -> under the Find resource type and metric entry field choose "Total bytes" or enter "storage.googleapis.com/storage/total_bytes" and click on the one that shows up. It'll then show you usage for all buckets in your project.

sabujp
  • 989
  • 1
  • 11
  • 12
6

As explained in du - Display object size usage we coul use gsutil command

gsutil -o GSUtil:default_project_id=[PROJECT-ID] du -shc

It will show all space of each of the buckets and total space used like this

24.18 MiB    gs://appspot.[PROJECT-ID].com
687.46 MiB   gs://artifacts.[PROJECT-ID].appspot.com
947 B        gs://[PROJECT-ID]_cloudbuild
252.55 MiB   gs://staging.[PROJECT-ID].appspot.com
9.36 GiB     gs://us.artifacts.[PROJECT-ID].appspot.com
10.3 GiB     total

Note if you get "ImportError: No module named google_compute_engine" please refer to this issue. Can be solved by running export BOTO_CONFIG=/dev/null before running gsutil.

eQ19
  • 9,880
  • 3
  • 65
  • 77
1

You can also get this information through the API, like in this python example:

import os
from google.cloud import storage

os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = "/path/to/my/credentials.json"
bucket_name = "my-bucket-name"
storage_client = storage.Client()
bytes_used = sum(
    [blob.size for blob in storage_client.list_blobs(bucket_name)]
)
print(
    f"{bucket_name} is using {bytes_used/1048576:0.3f} MiB."
)
Josh Davis
  • 1,793
  • 1
  • 15
  • 21