google-cloud-platformgoogle-bigquerygoogle-cloud-storagegoogle-kubernetes-enginegoogle-cloud-billing

More Detailed Billing Information of GCS Buckets


I have multiple GKE clusters with logically separated K8s objects using namespaces, each namespace has GCS bucket attached to it (Statefulset) I wanted to know billing information about each namespace and what each namespace costs for resources usage. I found very useful feature called "GKE Metering" and yea it showed up some useful information about CPU and Memory billing info for each namespace by gathering billing information and import it into BigQuery, then I can visualize the results using Google Data Studio for example.

The Question Is:

  1. How can I get billing information of each GCS bucket which attached to each namespace to be visualised?
  2. How to get billing information fo each namespace usage of Filestore Instance?

Any help will be appreciated 🙌🏻 Thank you


Solution

  • For that, you need to add a label on your GCS bucket

    Then to export the billing to BigQuery

    And to get the data like that in BigQuery

    SELECT * 
    FROM `project.dataset.exportBillingTable` 
    WHERE "<Your Label Key>" IN UNNEST(labels.key)
    

    You can perform "group by", "sum", filter on the label key or the label value,...