Overview
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.
Note that regular file export to CSV and JSON captures a smaller dataset than export to BigQuery. For example, the exported Cloud Billing data does not include any invoice-level charges such as taxes accrued or adjustment memos. If you need to reconcile your exported data to your invoices, you should use export to BigQuery.
Usage data is labeled with the 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
Cloud project. To do so, you must have the
storage.objects.create
project permission for the 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:
- Overview of Access Control
- Create Custom Roles for Cloud Billing
- Understanding Predefined Identity and Access Management Roles
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:
Sign in to the Google Cloud Console.
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 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.
In the Billing navigation menu, select Billing export.
Select the File export tab.
Click Edit settings to enable export and update the export settings.
For Bucket name, specify the name of the Cloud Storage bucket into which Cloud Billing data will be automatically published.
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.
For Format, select CSV or JSON.
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
When you first enable export to a file in a Cloud Storage bucket, it might take a few hours to start seeing your Google Cloud billing data.
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 Cloud project number Example: 333809197194
|
projectId (Project ID) |
Metric Type: string Description: The ID of the Cloud project Example: my-app-project
|
projectName (Project Name) |
Metric Type: string Description: The name of the Cloud project Example: My first app project
|
projectLabels (Project Labels) |
Metric Type: string Description: Labels attached to a 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
|
Related topics
- Export Cloud Billing data to BigQuery
- View your Cloud Billing reports and cost trends
- Understand your savings with cost breakdown reports
- Analyze the effectiveness of your committed use discounts
- View your cost and payment history
- Get an invoice, statement, or receipt