Google Cloud Platform - Billing and Usage Extractor
Use the Google Cloud Platform - Billing and Usage Extractor to collect the cost and usage data of your virtual machine instances that are provisioned in the Google Cloud Platform (GCP) cloud. The TrueSight Cloud Cost Control uses the cost and usage data to provide forecasting, simulated migration, and cost estimations.
The ETL makes the API calls for data collection.
If your setup is behind a firewall, ensure that the ETL can access the following API endpoints:
- Billing: cloudbilling.googleapis.com
- Stackdriver logging: logging.googleapis.com
- Stackdriver monitoring: monitoring.googleapis.com
- Cloud Resource manager: cloudresourcemanager.googleapis.com
- Compute engine: compute.googleapis.com
- Storage bucket: storage-component.googleapis.com
- Authentication: oauth2.example.com, www.googleapis.com
Additionally, if you encounter issues with API requests due to 1e100.net domain, include it in the firewall allow rules.
This ETL is used in conjunction with the Google Cloud Platform - GCP API Extractor. The cost and usage data that the GCP Billing and Usage ETL collects is associated with the business service entities and resources that are collected by the GCP API ETL.
To learn more about the collection of business service data by ETLs, see Collecting business service data.
Collecting data by using the GCP Billing and Usage ETL
To collect data by using the GCP Billing and Usage ETL, do the following tasks:
I. Complete the preconfiguration tasks.
II. Configure the ETL.
III. Run the ETL.
Before you configure and run the ETL, complete the following tasks to enable the ETL to collect the cost and usage data of your GCP project resources:
Step | Details |
---|---|
Subscribe to the Google Cloud Platform. Important Ensure that you create an account only in US dollar. The ETL does not support other currencies. |
|
Create projects to manage virtual machine instances, billing, and Cloud Platform services.
|
|
Create a service account to authenticate applications that run on your virtual machine instances to access other Google Cloud Platform services. If you want to retrieve data for multiple projects by using a single ETL, create a separate Service account key file for each project.
Important Ensure that the following roles are assigned to the service account: compute.viewer and storage.objectViewer |
|
Create a billing account. | |
Add the email addresses of the service accounts for all the linked projects to the billing account with the Billing Account Viewer role. | |
Link projects to a billing account so that the costs that are incurred for the projects are added to the billing account. You can link all your projects to a single billing account or can link each project to a separate billing account. | |
Create separate buckets to store the billing and usage data of your projects. The billing data of all the projects that are associated with a billing account is stored in a single bucket. However, the usage data of a project is stored in the project-specific bucket. Important Ensure that the storagelegacyBucketReader role is assigned to each storage bucket. | |
Enable the generation of a billing report so that the ETL can collect the billing details of your project resources. GCP generates billing reports either monthly or when your account exceeds certain charges, which is known as threshold billing. | |
Enable the generation of a usage report so that the ETL can collect the usage data of the project resources. | |
Enable the cloud storage and billing APIs to collect the billing and usage data. | |
Create a configuration file to collect the usage data of multiple projects. The configuration file is a text file that contains the following details of each project on separate lines:
Important Ensure that the header statement is available at the beginning of the configuration file. For details, see the attached sample configuration file. | Click here to view a sample configuration file. |
Create a Cloud Billing API key. You can use the Cloud Billing API to programmatically manage billing accounts and projects. | |
Ensure that the time is correctly set on the host where the ETL engine runs. | BMC recommends to use the Network Time Protocol (NTP) client and synchronize the host clock with the network time server. |
You must configure the ETL to connect to GCP for data collection. ETL configuration includes specifying the basic and optional advanced properties. While configuring the basic properties is sufficient, you can optionally configure the advanced properties for additional customization.
A. Configuring the basic properties
Some of the basic properties display default values. You can modify these values when required.
To configure the basic properties:
- In the TrueSight Capacity Optimization console, navigate to Administration > ETL & System Tasks, and select ETL tasks.
On the ETL tasks page, click Add > Add ETL. The Add ETL page displays the configuration properties. You must configure properties in the following tabs: Run configuration, Entity catalog, and Google Cloud configuration
On the Run Configuration tab, select Google Cloud Platform - Billing and Usage Extractor from the ETL module list. The name of the ETL is displayed in the ETL task name box. You can edit this field to customize the name.
- Click the Entity catalog tab, and select one of the following options:
Shared Entity Catalog:Retain the default selection to share the entity catalog with the GCP API ETL, which extracts infrastructure data of your GCP resources.
- From the Sharing with Entity Catalog list, select the entity catalog name that is shared between ETLs.
- Private Entity Catalog: Select if this is the only ETL that extracts data from the GCP resources.
Click the Google Cloud configuration tab, and configure the following properties:
Depending on your GCP project setup, configure the ETL to collect the usage data of a single project or multiple projects.
To collect the usage data of a single project, configure these properties:
Property Description Google Cloud project access mode Select Single. Billing report bucket name Specify the name of the Google Cloud Storage bucket that contains the billing reports of your project. Billing report prefix Specify a prefix to be used for the billing reports. Service account key file path Specify the directory path where the service account key file of the project that contains the billing bucket is available. For example, /project_name/GCP/gcp_project.json Usage report bucket name Specify the name of the bucket where the usage report of your project resources is stored. Usage report prefix Specify a prefix to be used for the usage reports. Business Service Tag Key Specify the business service tag key that is used by the GCP API ETL for organizing entities according to business services. The GCP Billing and Usage ETL uses the specified tag key to associate the resource cost to the entities that are categorized under business services.
The default tag key is service.
Cloud billing API Key Specify the key that you created for the Cloud Billing API. The ETL uses this key to retrieve details, such as billable Stock Keeping Units (SKUs), public pricing, and relevant metadata. To collect the usage data of multiple projects, configure these additional properties:
Property
Description Google Cloud project access mode Select Multiple. Service account key file path Specify the directory path where your service account key files are available. Multiple project configuration file path Specify the directory path that contains the configuration file that you created during the preconfiguration procedure. The file contains the details of your projects, such as service account key file path and project usage report bucket.
The following image shows sample configuration values for the basic properties:
(Optional) Override the default values of properties in the following tabs:
- Click Save.
The details of the newly configured GCP Billing and Usage ETL are displayed.
(Optional) B. Configuring the advanced properties
You can configure the advanced properties to change the way the ETL works and to define the data collection period.
To configure the advanced properties:
- On the Add ETL page, click Advanced.
Configure the following properties:
- Click Save.
The ETL tasks page shows the details of the newly configured GCP Billing and Usage ETL.
After you configure the ETL, you can run it to collect data. You can run the ETL in the following modes:
A. Simulation mode: Only validates connection to the data source, does not collect data. Use this mode when you want to run the ETL for the first time or after you make any changes to the ETL configuration.
B. Production mode: Collects data from the data source.
Important
Ensure that you first run the GCP API ETL before running the GCP Billing and Usage ETL.
A. Running the ETL in the simulation mode
To run the ETL in the simulation mode:
- In the TrueSight Capacity Optimization console, navigate to Administration > ETL & System Tasks, and select ETL tasks.
- On the ETL tasks page, click the ETL. The ETL details are displayed.
- In the Run configurations table, click Edit to modify the ETL configuration settings.
- On the Run configuration tab, ensure that the Execute in simulation mode option is set to Yes, and click Save.
- Click Run active configuration. A confirmation message about the ETL run job submission is displayed.
- On the ETL tasks page, check the ETL run status in the Last exit column.
OK Indicates that the ETL ran without any error. You are ready to run the ETL in the production mode. - If the ETL run status is Warning, Error, or Failed:
- On the ETL tasks page, click in the last column of the ETL name row.
- Check the log and reconfigure the ETL if required.
- Run the ETL again.
- Repeat these steps until the ETL run status changes to OK.
B. Running the ETL in the production mode
You can run the ETL manually when required or schedule it to run at a specified time.
Running the ETL manually
- On the ETL tasks page, click the ETL. The ETL details are displayed.
- In the Run configurations table, click Edit to modify the ETL configuration settings. The Edit run configuration page is displayed.
- On the Run configuration tab, select No for the Execute in simulation mode option, and click Save.
- To run the ETL immediately, click Run active configuration. A confirmation message about the ETL run job submission is displayed.
When the ETL is run, it collects data from the source and transfers it to the TrueSight Capacity Optimization database.
Scheduling the ETL run
By default, the ETL is scheduled to run daily. You can customize this schedule by changing the frequency and period of running the ETL.
To configure the ETL run schedule:
- On the ETL tasks page, click the ETL, and click Edit. The ETL details are displayed.
On the Edit task page, do the following, and click Save:
- Specify a unique name and description for the ETL task.
- In the Maximum execution time before warning field, specify the duration for which the ETL must run before generating warnings or alerts, if any.
- Select a predefined or custom frequency for starting the ETL run. The default selection is Predefined.
- Select the task group and the scheduler to which you want to assign the ETL task.
Click Schedule. A message confirming the scheduling job submission is displayed.
When the ETL runs as scheduled, it collects data from the source and transfers it to the TrueSight Capacity Optimization database.
Verify that the ETL ran successfully and the GCP cost data is refreshed in the TrueSight console.
To verify whether the ETL ran successfully:
- In the TrueSight Capacity Optimization console, click Administration > ETL and System Tasks > ETL tasks.
- In the Last exec time column corresponding to the ETL name, verify that the current date and time are displayed.
To verify whether the Google cost data is refreshed:
- Log in to the TrueSight console.
- Click Cloud Cost Control, and verify whether the GCP cost data is refreshed.
Comments
Log in or register to comment.