Export Cloud Billing Data to a File

To access a detailed breakdown of your charges, you can export your daily usage and cost estimates automatically to a CSV or JSON file stored in a Cloud Storage bucket you specify. You can then access the data by using the Cloud Storage API, CLI tool, or Google Cloud Console.

Usage data is labeled with the Google Cloud project number and resource type. You use access-control lists (ACLs) on your Cloud Storage bucket to control who can access this data.

How to enable Cloud Billing export to a file

Required permissions

To enable and configure the export of Google Cloud billing data to a file stored in a Cloud Storage bucket, you need the following permissions:

  • For Cloud Storage, you need permissions to create a bucket in a Google Cloud project. To do so, you must have the storage.objects.create project permission for the Google Cloud project where you are creating the bucket. If you are working within a project that you did not create, you might need the project owner to give you a role that contains this permission, such as Editor, Owner, or Storage Admin.
  • For Cloud Billing, you need the Billing Account Administrator role for the target Cloud Billing Account.

For more information about Google Cloud permissions, see:

1. Create a bucket in Cloud Storage

If you haven't already created a bucket in Cloud Storage, you need to create one. For instructions, see Creating Cloud Storage Buckets.

2. Enable Cloud Billing export to a file

After you have created a bucket in Cloud Storage, do the following to enable Cloud Billing export to a file:

  1. Sign in to the Google Cloud Console.

    Sign in to Cloud Console

  2. Open the console Navigation menu (), and then select Billing.

    If you have more than one Cloud Billing Account, do one of the following:

    • To manage Cloud Billing for the current Google Cloud project, select Go to linked billing account.
    • To locate a different Cloud Billing Account, select Manage billing accounts and choose the account for which you'd like to enable Cloud Billing data export to a file.
  3. In the Billing navigation menu, select Billing export.

  4. Select the File export tab.

  5. Click Edit settings to enable export and update the export settings.

  6. For Bucket name, specify the name of the Cloud Storage bucket into which Cloud Billing data will be automatically published.

  7. For Report prefix, specify a prefix for the Cloud Storage object name for the exported reports. The year, month, and day is appended to the prefix.

  8. For Format, select CSV or JSON.

  9. Click Save.

Bucket permissions

When you enable Cloud Billing export to automatically publish daily billing data in a CSV or JSON file, the file is stored in a Cloud Storage bucket that you specify. To allow this automation, a Google-owned service account is automatically added as a member of the bucket's permissions, and granted write access to the bucket (using the Storage Legacy Bucket Writer role). The service account looks like this:

  • 000000000000-xxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com

The service account provides the permissions that are necessary to automatically publish the daily Cloud Billing data to the bucket. Do not delete this service account.

Data availability

Your Cloud Storage bucket only contains exported Cloud Billing JSON or CSV files starting from the date that you set up Cloud Billing export, and after.

Contents of the exported billing file

The following table describes the contents of the exported Cloud Billing JSON or CSV file. JSON metric names are listed first; CSV metric names are shown in parentheses under the JSON metric names.

Metric Metric Properties
accountId
(Account ID)
Metric Type: string
Description: The Cloud Billing Account ID
Example: 00D11E-FFCCD9-B44BAE
lineItemId
(Line Item)
Metric Type: string
Description: The URI of the specified resource
Example: com.google.cloud/services/compute-engine/ForwardingRuleChargeBase
startTime
(Start Time)
Metric Type: dateTime
Description: The start time of the measured time period
Example: 2019-11-14T00:00:00-07:00
endTime
(End Time)
Metric Type: dateTime
Description: The end time of the measured time period. The time period is one hour after the start time.
Example: 2019-11-14T01:00:00-07:00
projectNumber
(Project Number)
Metric Type: integer
Description: The Google Cloud project number
Example: 333809197194
projectId
(Project ID)
Metric Type: string
Description: The ID of the Google Cloud project
Example: my-app-project
projectName
(Project Name)
Metric Type: string
Description: The name of the Google Cloud project
Example: My first app project
projectLabels
(Project Labels)
Metric Type: string
Description: Labels attached to a Google Cloud project, returned as key value pairs. For example, if you created labels called cost-center and geo and the project values for those labels are apac and my-cost-center, the metrics returned would be:
JSON:
{"geo":"apac","cost-center":"my-cost-center"}
CSV:
geo:apac;cost-center:my-cost-center
For more information about labels, see the Google Cloud blog, Using labels to organize Google Cloud resources.
Measurements
measurementId
(Measurement)
Metric Type: string
Description: URI of the specified resource
Example: com.google.cloud/services/compute-engine/ForwardingRuleChargeBase
sum
(Measurement Total Consumption)
Metric Type: integer
Description: The calculated time period
Example: 86400
unit
(Measurement Units)
Metric Type: string
Description: The time period units of measurement
Example: seconds
Credits
creditId
(Credit)
Metric Type: string
Description: The credit ID
Example: 008F74-21254F-7E5A81::3WDRCXQ9AHU4FK-81
amount
(Credit Amount)
Metric Type: decimal
Description: The calculated credit amount
Example: -0.000024
currency
(Credit Currency)
Metric Type: string
Description: The currency code
Example: USD
Cost
amount
(Cost)
Metric Type: decimal
Description: The calculated cost
Example: 0.59904
currency
(Currency)
Metric Type: string
Description: The currency code
Example: USD
Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Billing
Need help? Visit our support page.