Configuring Cost for GCP
Prerequisites
- Ensure you have a GCP project with billing enabled.
- Create a BigQuery dataset and table to store detailed usage cost data.
- Create a service account with the necessary permissions to access the BigQuery dataset and table. The service account must have the following roles:
BigQuery Data Viewer
BigQuery Job User
Billing Account Viewer
- Download the service account key in JSON format. This will be used in Torque.
Configuration Steps
Step 1: Set up BigQuery for Cost Data
- In your GCP Console, navigate to BigQuery.
- Create a dataset to store cost data:
- Click Create Dataset.
- Enter a Dataset ID (e.g.,
cost_data
). - Set the Data location and other settings as needed.
- Click Create Dataset.
- Create a table for detailed usage cost data:
- Select the dataset you just created.
- Click Create Table.
- Set the Table ID (e.g.,
detailed_usage_cost
). - Define the schema for the table based on your cost data requirements.
- Click Create Table.
Step 2: Create a Service Account
- In your GCP Console, navigate to IAM & Admin > Service Accounts.
- Click Create Service Account.
- Enter a Service Account Name (e.g.,
torque-cost-collector
). - Assign the following roles to the service account:
BigQuery Data Viewer
BigQuery Job User
Billing Account Viewer
- Click Done.
- Download the service account key in JSON format:
- Select the service account you just created.
- Click Keys > Add Key > Create New Key.
- Select JSON and click Create.
- Save the JSON file securely.
Step 3: Configure Torque
- Go to Administration > Cloud Accounts > Cost Collection Target in Torque.
- Click Add Cost Collection Target.
- Select GCP.
- Specify the following details:
- Name: A descriptive name for the cost collection target.
- Service Account Key JSON: Upload the JSON file downloaded in Step 2.
- Project ID: The GCP project ID where the BigQuery dataset resides.
- Dataset Name: The name of the BigQuery dataset (e.g.,
cost_data
). - Detailed Usage Cost Table Name: The name of the BigQuery table (e.g.,
detailed_usage_cost
).
- Click Finish.
- Click the cost collection target's 3-dot menu and select Validate to ensure the configuration works.
Step 4: Enable the Cost Collection Target
- Go to Administration > Cloud Accounts > Cost Collection Target.
- Click the desired cost collection target's Enabled toggle.
Troubleshooting
What can be done if you don't see cost in Torque's cost dashboard?
- Ensure that cost data is being exported to the BigQuery table. Check the table in the GCP Console to verify data is present.
- Validate the service account permissions:
- Ensure the service account has access to the BigQuery dataset and table.
- Verify the service account has the
Billing Account Viewer
role.
- Test your credentials in Torque:
- Navigate to Administration > Cloud Accounts > Cost Collection Target > Choose your cloud > In the three-dot menu, click on Validate.
- If issues persist, review the configuration steps above and correct any errors.