How to set up spend reporting in Terra GCP (Terra Billing project owners)

Allie Cliffe
  • Updated

Step-by-step instructions for setting up Google spend reporting in Terra. For most people, there are three steps (including verifying that you have the right permission) to setting up cost reporting. Once you complete these, workflows spend and cloud costs reports will appear automatically. 

For more background, see Displaying Google cloud costs in Terra.  

Not able to follow these directions?You must be an "Owner" of the Terra Billing Project and “Owner” or "Admin" on the Google Cloud Billing account. If at any point you are not able to follow the directions below, or do not see the options in the screenshots (or they are greyed out), it is likely because you do not have sufficient permissions on the Google Cloud Billing account. You will need to ask the owner for admin privileges on the Cloud Billing account or to set up a BigQuery dataset for billing export (follow directions below).

This may be the case, for example, if you are using a third-party resellers such as Onix.

Step 1: Verify your permissions

Verify you are a Billing project Owner 

1.1. Go to your billing page (app.terra.bio/#billing).

1.2. If the billing project is listed in the Owned by you section, you're all set.
Screenshot-of-billing-page-with-ac-billing-highlighted-under-owned-by-you.png
To find the Google Billing account associated with this Billing project: 1. click on the billing project link  2. Look next to Billing Account.
Set-up-spend-reporting_Screenshot-of-billing-project-details-page.png

1.3. If the Billing Project is under Shared with You, you can click on the Members tab to see who you would need to ask to get that permission. 

Verify you are a Google Cloud billing account Owner or Admin

1.4. Go to billing in Google Cloud console (https://console.cloud.google.com/billing) and click on the name of the Cloud Billing account linked to the Terra Billing project. 
Screenshot-of-My-billing-accounts-tab-in-Google-cloud-console-with-the-billing-project-JAC-billing-highlighted.png

1.5. If get an error message "You don’t have permission to view costs for this billing account", you will need to ask an owner to expand your role to be able to follow the directions below. 

What to do if you don't have Cloud billing account permission Click on the Manage billing account link at the top right (see the arrow in the screenshot below).
Screenshot-of-JAC-billing-account-overview-with-error-message-highlighted-and-arrow-pointing-to-manage-billing-account-link.png

Expand the Billing Account Administrator section to see who to ask to grant you permission.
Screenshot-of-billing-account-management-screen-with-role-principal-expanded-and-highlighted-to-show-the-admin-on-the-account.png

If you use third-party resellers, contact your reseller directly for help.

Step 2. Set up billing export (once per Cloud Billing account)

Terra needs to be able to access Google's cost reports (a spend reporting billing dataset on BigQuery) to enable the workflows spend reporting. Google Cloud account owners will set this up in Google Cloud.

You will only need to do this once per Google Cloud Billing account. 

Who can skip this step Some users already have billing export set up for their Cloud Billing account. Broad Google Cloud Billing account users and SADA users can skip this first step and go directly to Step 3: Configure the workflow spend report.

Set up billing export in GCP console

2.1. Navigate to the billing account management page in Google Cloud Console.

2.2. Click on the name of the billing account you would like to enable billing exports for.

If you have more than one Cloud Billing accountYou will need to repeat for each Google Cloud Billing account associated with a Terra Billing Project to enable in-app spend reporting.

2.3. Click on Billing export in the left sidebar (1) and the Edit settings button under Standard Usage costs (2).
Screenshot-of-billing-export-page-with-the-number-one-by-billing-export-at-left-and-the-number-two-poiinting-to-the-standard-usage-cost-edit-settings-button.png

Create of configure a native Google project for exported billing data

2.4. Next you will create or configure a non-Terra project to to host a BigQuery dataset for the exported billing data. 

Why do you need a Google project for the export dataset?

Storing the export data and querying the dataset will cost a (small amount) of money. The dataset project tracks how much and where to bill the charges.

The Billing project cannot be a Terra-generated workspace projectYou can also select an existing Google project from the dropdown, as long as  the ID in the dropdown does not start with terra-. If the project has that formatting, it was created by Terra and will not work for this step.
Screenshot-of-projects-in-dropdown-under-daily-cost-detail-with-arrow-pointing-to-a-Terra-created-project-terra-c587cc85.png

If you don't have a project, Google will prompt you to create one. 
Screen shot of Google prompt to create a project for cost reporting

If you only have Terra-generated projects

You will need to create a project to host your dataset.

2.4.1. Go to IAM & Admin (three horizontal lines at top left of the page) and click the button to Create Project
Screenshot-of-IAM-page-in-GCP-console-with-a-circle-around-the-Create-project-button-at-right.png

2.4.2. In the New Project form, fill in the name of your export billing project and select the Cloud Billing account and organization (if applicable).
Screenshot-of-new-project-page-in-GCP-console.png

Don't start your project name with terra-! That will make it hard to separate what is Terra-generated and what you created. 

Unable to create a project in Google?If you are unable to follow the instructions (especially if what's on your screen looks different than what's here), you most likely don't have the right permission.

What to do
If you are part of an organization, reach out to your Google Cloud Billing account admin or central organization. See instructions above for how to find the right person to ask. If you use a third-party reseller, reach out to the reseller to ask for help.

Create the BigQuery dataset to store the billing export data

2.5. In the page for the export dataset Google project in GCP console, click on Create new dataset.
Screenshot-of-dataset-under-daily-cost-detail-highlighting-link-to-create-new-dataset.png
2.6.
Then fill in the Create dataset form fields

Suggestions/requirements

  • Dataset ID: append _bq for easy identification (i.e., daily_terra_cost_details_bq)
  • Location (Region > us-central1
    Create-dataset-form-with-ID-field-and-location-us-central1-filled-in.png

2.7. Click the Create dataset button at the bottom.

2.8. Click the blue Save button. 

Retrieve the project ID and dataset name

2.9. Next to Dataset name, click on the link to the dataset you just created (circled in the screenshot below).
Screenshot-of-terra_daily_cost_bq-dataset-link.png

2.10. From the Dataset info page, copy the Google project ID (to the left of the period) and BigQuery dataset name (to the right of the period) to a safe place. You will need these variables to configure spend reporting in Terra (3.4 below).  

How to find Google project ID and BigQuery dataset name

The format is Google project ID . BigQuery dataset name (separated by a period).

In the screenshot below, the GoogleProjectID is billing-export-project-452020and the BigQuery dataset name is terra_daily_cost_details_bq.Screenshot-of-BigQuery-dataset-info-showing-Google-project-and-dataset-name-circled.jpg

Grant Terra permission to view the dataset

2.11. Next you'll give Terra permission to view the billing export dataset. Go to the sharing dropdown above and to the right of the Dataset info and click Permissions
Dataset-info-in-GCP-console-with-sharing-permissions-menu-highlighted.png

If this option is greyed out, it is most likely because your role doesn't allow you to share the dataset. You will need to ask the owner of the Google Cloud Billing account to grant you permission to share a BigQuery dataset. 

2.12. Select the Add principals button in the Dataset Permissions section.

2.13. Type spend-reporting@terra.bio into the New Principals field (circled in screenshot below) and select BigQuery Data Viewer from the Role dropdown (arrow). This grants Terra permission to access the dataset you've just set up.
Add-Principals-form-on-Google-Cloud-console.png

2.14. Click the Save button (at the bottom of the form).

Google BigQuery billing exports are now configured for this Cloud Billing account. You can confirm by expanding the menu under BigQuery Data Viewer (below).
Screenshot-of-BigQuery-dataset-permissions-after-adding-terra-as-viewer.png

The next step will be Step 3: Configure workflow spend report in Terra.

  • If you use STRIDES

    2.1. Navigate to https://console.cloud.google.com/ and select your project ID.

    2.2. Select Menu > BigQuery.

    2.3. Follow the instructions to create a dataset daily_cost_reporting.

    2.4. Share the daily_cost_reporting dataset with spend-reporting@terra.bio as BigQuery Dataset Viewer.

    If you use a third-party reseller

    You may need to ask them to set up the spend reporting (in GCP console) for you.

    2.1. Create a BigQuery dataset daily_cost_reporting for exporting Google billing data.

    2.2. Share the daily_cost_reporting dataset with spend-reporting@terra.bio as BigQuery Dataset Viewer.

    2.3. Give you the Google project ID of the dataset (to use in Step 2 below).

Before you move on to step 3If you just completed Step 2 we recommend you wait several hours to complete Step 3 in order for billable activity to be recorded in BigQuery or you may receive an error that the dataset cannot be found.

Step 3. Configure workflow spend reporting in Terra

Now that you have set up billing data export in Google Cloud, you will set up (configure) spend reporting in Terra. You will only need to do this once per Terra Billing project. 

Do you have multiple billing projects?If you have workspaces in multiple billing projects that you want to set up with spend reporting, be sure to repeat the following steps for each billing project.

3.1. Go to the Billing page by first clicking your name and selecting Billing from the main navigation menu (top left of any page in Terra).
Workflow-spend-report_Configure-Billing_Screen_shot.png

3.2. Select the Terra Billing project you want to enable spend reporting for.

Note that you need to be an owner to follow these steps. You'll know you're the owner if you see the Terra billing project listed under Owned by You in the top left column. 
Set-up-spend-reporting_Screenshot-of-billing-page-with-Terra-billing-project-ac-billing-circled-under-owned-by-you.png

3.3. Click the pencil icon beside Workflow Spend Report Configuration to edit. 
Set-up-spend-reporting_Screenshot-of-ac-billing-details-page-highlighting-Spend-report-configuration-and-pencil-icon.png

3.4. Fill in the Dataset Project ID (i.e., Google project ID) and Dataset Name (i.e., BigQuery dataset name) from GCP console (step 1.11 for general users or step 1.9 for STRIDES - above) in the Configure Spend Reporting form.
Set-up-spend-reporting_Screenshot-of-configure-spend-report-popup.png

2.5. Click the OK button to save.

What to expect

You will not get a confirmation message, but as long as you don't get an error message, your configuration should be saved. 

If you get an error that looks like this

Set-up-spend-report_Error-updating-spend-report-configurations.png

Example error text

Error updating workflow spend report configuration
The billing export table <name here> in dataset <dataset name> could not be found

Full error

{
 "causes": [],    "message": "The billing export table gcp_villing_export_v1_012061_174696_8A47BC in dataset terra_daily_cost_details could not be found.",    "source": "rawls",    "stackTrace": [],
 "statusCode": 400,    "timestamp": 1631824489662 }

What is happening?

This error occurs when there is currently no data in the dataset. 

To remedy this, try the following

  1. Run a small workflow in the workspace.

  2. Wait 2-3 hours and follow steps 2.1 - 2.5 again. 

For more granular cost details

Se step-by-step instructions for querying the billing export dataset directly here

 

Was this article helpful?

1 out of 1 found this helpful

Comments

0 comments

Please sign in to leave a comment.