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.

Step I. Complete the preconfiguration tasks

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:

StepDetails

Subscribe to the Google Cloud Platform.

Important

Ensure that you create an account only in US dollar. The ETL does not support other currencies.

    1. Log in to the Google Cloud Platform console with your Google account credentials.
    2. Select your email preferences, accept the terms of service, and click Agree and continue.
    3. Sign up for a free trial or apply for a paid subscription.

Create projects to manage virtual machine instances, billing, and Cloud Platform services.

All the Google Cloud Platform resources, such as Google Compute Engine virtual machines, Google Cloud Storage buckets, and Google App Engine instances are grouped under a project. Projects are required for using all Cloud Platform services, managing APIs, enabling billing, adding and removing collaborators, and managing permissions.


    1. Log in to the Google Cloud Platform console with your Google account credentials.
    2. On the upper-left corner of the page, click Select a project next to Google Cloud Platform.

      If you have already created projects and updated any of them, the name of the last project that you worked on is displayed besides Google Cloud Platform. In this scenario, click the project name.

    3. Click the plus (plus) icon that is next to the search projects and folders text box.
    4. In the Project name field, specify a name for your project. The project ID is generated automatically.
    5. Click Create.
    6. On the upper-left corner of the page, click Select a project or the project name next to Google Cloud Platform. Your recently created project name is displayed in the list.
    7. Select the project, and click Open.
      The project dashboard is displayed, and you can start working in the project.

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.

A service account acts as an identity for an instance or an application that runs on a virtual machine. You can use service accounts to create instances and other resources. A single instance can belong to a single service account only, and you can change the service account for the instance.

Important

Ensure that the following roles are assigned to the service account: compute.viewer and storage.objectViewer


    1. Log in to the Google Cloud Platform console with your Google account credentials.
    2. From the left navigation pane, click IAM & admin > Service accounts.
    3. Click Create Service Account.
    4. On the Create service account page, complete these steps:
      1. Specify a name for the service account. The service account ID is generated automatically.
      2. Select Compute Engine > Compute Viewer. This role provides read-only access to Compute Engine resources.



      3. Click Add Another Role, and select Monitoring > Monitoring Viewer. This role provides read-only access to monitoring and configuration data.
      4. (Optional) Grant access to specific users to use or administer this service account.
      5. Click Create Key, and retain the default selection as JSON for the key type.
      6. Click Create.
        The settings are saved, and a confirmation message is displayed. The private key for the account is saved to your computer.

        Ensure that you save this key securely. If this key is lost or tampered, you need to create a new key.

Create a billing account.

A billing account is a payment profile that contains payment-related settings, such as payment method and a billing address. Each project is attached to a billing account, and any costs that are incurred for the project are added to the billing account. Multiple projects can be attached to a single billing account.


    1. Log in to the Google Cloud Console with your Google account credentials.
    2. In the left navigation pane, click Billing > Manage billing accounts.
    3. If this is your first billing account, complete the following steps. Otherwise, go to step 4.
      1. Click Add billing account.
      2. On the Try Cloud Platform for free page, specify your country, accept the terms of service, and click Agree and continue.
      3. On the customer information page, add the details, such as account type, tax status, name and contact, and the credit card number.
      4. Click Start my free trial.
        If the specified details such as card number are correct, a confirmation message about the generation of the billing account is displayed.
    4. If you already have some existing billing accounts and want to create a new billing account, complete these steps:
      1. Click Create account.
      2. In the Name field, specify a name for the billing account, and click Continue.
      3. Verify your country and currency, and click Confirm.
      4. On the payments profile page, enter your billing information, such as account type, tax status, name and address, credit card details, and click Submit and enable billing.
      5. On the verification page, enter the 3-letter CVV number that is on the back of your card, and click Continue.
        The billing account is created and is added to the list of existing billing accounts.

Add the email addresses of the service accounts for all the linked projects to the billing account with the Billing Account Viewer role.

    1. Log in to the Google Cloud Console with your Google account credentials.
    2. Select the project that is linked to your billing account.
    3. In the left navigation pane, click IAM & admin > Service accounts.
    4. Note down the email address of the service account that you want to use.
    5. Repeat steps b to d till you obtain the email addresses of the service accounts for all the projects that are linked to your billing account.
    6. In the left navigation pane, click Billing > Go to linked billing account.

    7. Under My Billing Account, complete these steps:
      1. In the Add members field, add the email addresses of the service accounts that you obtained in the earlier steps.
      2. From the Select a role list, select Billing > Billing Account Viewer.
      3. Click Add.
        A confirmation message about the addition of members is displayed.

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.

    1. Log in to the Google Cloud Console with your Google account credentials.
    2. On the upper-left corner of the page, click Select a project or the project name next to Google Cloud Platform, and select a project from the list.
    3. In the left navigation pane, click Billing > Link a billing account.
    4. From the Billing account list, select the required billing account, and click SET ACCOUNT.
      You are directed to the billing summary page that displays the current status of remaining credits, and a list of projects that are attached to the billing account.
      If a billing account is not available, you are prompted to create the 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.



    1. Log in to the Google Cloud Console with your Google account credentials.
    2. On the upper-left corner of the page, click Select a project or the project name next to Google Cloud Platform, and select a project from the list.
    3. In the left navigation pane, click Storage > Browser, and then click CREATE BUCKET.
    4. On the Create a bucket page, specify the following details:
      1. In the Name field, specify a bucket name. Ensure that the name is according to the bucket naming guidelines.
      2. From the Default storage class list, select an appropriate default storage class. This class is assigned to the objects that are stored in the bucket.
      3.  From the Multi-Regional location list, select a location where you want to store the bucket data.
      4. Click Create.
        The bucket is created and displayed in the Browser tab.

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.

    1. Log in to the Google Cloud Console with your Google account credentials.
    2. On the upper-left corner of the page, click Select a project or project name besides Google Cloud Platform, and select a project from the list.
    3. In the left navigation pane, click Billing > Go to linked billing account.
    4. Click Billing export > File export.
    5. In the Bucket Name field, specify the name of the bucket where you want to export the billing reports. The write access is granted to the associated service account.
    6. In the Report prefix field, specify a prefix for the Cloud Storage object name for the exported reports. The year, month, and day are appended to the prefix.
    7. From the Format list, select CSV or JSON.
    8. Click Enable billing report.

Enable the generation of a usage report so that the ETL can collect the usage data of the project resources.

    1. Log in to the Google Cloud Console with your Google account credentials.
    2. On the upper-left corner of the page, click Select a project or project name besides Google Cloud Platform, and select a project from the list.
    3. In the left navigation pane, click Compute Engine > Settings.
    4. Select the Enable usage report check box.
    5. In the Cloud Storage bucket field, enter a bucket name or click Browse and select a bucket name. The daily usage reports are stored in this bucket.
    6. (Optional) In the Report prefix field, specify a prefix for the Cloud Storage object name for the exported reports. The year, month, and day is appended to the prefix.
    7. Save the changes.

Enable the cloud storage and billing APIs to collect the billing and usage data.

    1. Log in to the Google Cloud Console with your Google account credentials.
    2. In the left navigation pane, click APIs and services > Dashboard. A list of APIs that are enabled is displayed.
    3. Verify that the Google Cloud Storage and Google Cloud Billing API are enabled. If they are disabled, perform these steps to enable them:
      1. Click Enable APIS and Services.
      2. Search for the required APIs, select them, and click Enable.
        The APIs are added to the list of enabled APIs.

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:

  • Service account key file path for the usage report
  • Project usage report bucket
  • Project usage report prefix

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.

  1. Log in to the Google Cloud Console with your Google account credentials.
  2. In the left navigation pane, click APIs and services > Credentials.
  3. Click Create credentials > API key. The key is generated.
  4. Click Restrict Key.
  5. Under Application restrictions, ensure that None is selected.
  6. Click API restrictions, select Cloud Billing API from the list, and save the changes.
    A confirmation message is displayed.

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.

Step II. Configure the ETL

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:

  1. In the TrueSight Capacity Optimization console, navigate to Administration ETL & System Tasks, and select ETL tasks.
  2. 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



  3. 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.

  4. 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.
  5. 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:

      PropertyDescription
      Google Cloud project access modeSelect Single.
      Billing report bucket nameSpecify the name of the Google Cloud Storage bucket that contains the billing reports of your project.
      Billing report prefixSpecify a prefix to be used for the billing reports.
      Service account key file pathSpecify 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 nameSpecify the name of the bucket where the usage report of your project resources is stored.
      Usage report prefixSpecify 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 KeySpecify 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 pathSpecify the directory path where your service account key files are available.
      Multiple project configuration file pathSpecify 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:

  6. (Optional) Override the default values of properties in the following tabs:

    PropertyDescription
    Module selection

    Select one of the following options:

    • Based on datasource: This is the default selection.
    • Based on Open ETL template: Select only if you want to collect data that is not supported by TrueSight Capacity Optimization.
    Module descriptionA short description of the ETL module.
    Execute in simulation modeBy default, the ETL execution in simulation mode is selected to validate connectivity with the data source, and to ensure that the ETL does not have any configuration issues. In the simulation mode, the ETL does not load data into the database. This option is useful when you want to test a new ETL task. To run the ETL in the production mode, select No.
    BMC recommends that you run the ETL in the simulation mode after ETL configuration and then run it in the production mode.

    PropertyDescription
    Task groupSelect a task group to classify the ETL.
    Running on schedulerSelect one of the following schedulers for running the ETL:
    • Primary Scheduler: Runs on the Application Server.
    • Generic Scheduler: Runs on a separate computer.
    • Remote: Runs on remote computers.
    Maximum execution time before warningIndicates the number of hours, minutes, or days for which the ETL must run before generating warnings or alerts, if any.
    Frequency

    Select one of the following frequencies to run the ETL:

    • Predefined: This is the default selection. Select an hourly, daily, or weekly frequency, and then select a time and a day to start the ETL run accordingly.
    • Custom: Specify a custom frequency, select an appropriate unit of time, and then specify a day and a time to start the ETL run.

  7. 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:

  1. On the Add ETL page, click Advanced.
  2. Configure the following properties:

    PropertyDescription
    Run configuration nameSpecify the name that you want to assign to this ETL task configuration. The default configuration name is displayed. You can use this name to differentiate between the run configuration settings of ETL tasks.
    Deploy statusSelect the deploy status for the ETL task. For example, you can initially select Test and change it to Production after verifying that the ETL run results are as expected.
    Log levelSpecify the level of details that you want to include in the ETL log file. Select one of the following options:
    • 1 - Light: Select to add the bare minimum activity logs to the log file.
    • 5 - Medium: Select to add the medium-detailed activity logs to the log file.
    • 10 - Verbose: Select to add detailed activity logs to the log file.

    Use log level 5 as a general practice. You can select log level 10 for debugging and troubleshooting purposes.

    Datasets

    Specify the datasets that you want to add to the ETL run configuration. The ETL collects data of metrics that are associated with these datasets.

    1. Click Edit.
    2. Select one (click) or more (shift+click) datasets from the Available datasets list and click >> to move them to the Selected datasets list.
    3. Click Apply.

    The ETL collects data of metrics associated with the datasets that are available in the Selected datasets list.

    Property

    Description
    Extraction mode
    The extraction mode denotes the data collection period. Depending on the period you want to collect data for, select one of the following options:
    • Regular - daily import: Select to collect daily data. In the first run, the ETL collects data for the past six months. On the subsequent runs, it collects the daily data (after the last counter value).
    • Historical - import historical data (do not use for daily scheduling): Select to collect the historical data for the period that you specify in the Extraction months property.
      The default historical data collection period is 12 months.

    Recommendation

    BMC recommends that you create a separate Run configuration to extract historical data. Do not use the same Run configuration for your daily runs and historical data extraction.

    By default, Regular is selected. After you run the ETL, the last counter value (LAST_EXTRACTION_MAX_TIME) is set to the day when the data was last extracted.

    PropertyDescription
    List of properties

    Specify additional properties for the ETL that act as user inputs during run. You can specify these values now or you can do so later by accessing the "You can manually edit ETL properties from this page" link that is displayed for the ETL in the view mode.

    1. Click Add.
    2. In the etl.additional.prop.n field, specify an additional property.
    3. Click Apply.
      Repeat this task to add more properties.

    PropertyDescription
    Empty dataset behaviorSpecify the action for the loader if it encounters an empty dataset:
    • Warn: Generate a warning about loading an empty dataset.
    • Ignore: Ignore the empty dataset and continue parsing.
    ETL log file nameThe name of the file that contains the ETL run log. The default value is: %BASE/log/%AYEAR%AMONTH%ADAY%AHOUR%MINUTE%TASKID
    Maximum number of rows for CSV outputA numeric value to limit the size of the output files.
    CSV loader output file nameThe name of the file that is generated by the CSV loader. The default value is: %BASE/output/%DSNAME%AYEAR%AMONTH%ADAY%AHOUR%ZPROG%DSID%TASKID
    Capacity Optimization loader output file nameThe name of the file that is generated by the TrueSight Capacity Optimization loader. The default value is: %BASE/output/%DSNAME%AYEAR%AMONTH%ADAY%AHOUR%ZPROG%DSID%TASKID
    Detail mode
    Specify whether you want to collect raw data in addition to the standard data. Select one of the following options:
    • Standard: Data will be stored in the database in different tables at the following time granularities: Detail (configurable, by default: 5 minutes), Hourly, Daily, and Monthly.
    • Raw also: Data will be stored in the database in different tables at the following time granularities: Raw (as available from the original data source), Detail (configurable, by default: 5 minutes), Hourly, Daily, and Monthly.
    • Raw only: Data will be stored in the database in a table only at Raw granularity (as available from the original data source).

    For more information, see Accessing data using public views Open link and Sizing and scalability considerations. Open link

    Remove domain suffix from datasource name (Only for systems) Select True to remove the domain from the data source name. For example, server.domain.com will be saved as server. The default selection is False.
    Leave domain suffix to system name (Only for systems) Select True to keep the domain in the system name. For example: server.domain.com will be saved as is. The default selection is False.
    Update grouping object definition (Only for systems) Select True if you want the ETL to update the grouping object definition for a metric that is loaded by the ETL. The default selection is False.
    Skip entity creation (Only for ETL tasks sharing lookup with other tasks) Select True if you do not want this ETL to create an entity and discard data from its data source for entities not found in Capacity Optimization. It uses one of the other ETLs that share a lookup to create a new entity. The default selection is False.

    PropertyDescription
    Hour maskSpecify a value to run the task only during particular hours within a day. For example, 0 – 23 or 1, 3, 5 – 12.
    Day of week maskSelect the days so that the task can be run only on the selected days of the week. To avoid setting this filter, do not select any option for this field.
    Day of month maskSpecify a value to run the task only on the selected days of a month. For example, 5, 9, 18, 27 – 31.
    Apply mask validationSelect False to temporarily turn off the mask validation without removing any values. The default selection is True.
    Execute after timeSpecify a value in the hours:minutes format (for example, 05:00 or 16:00) to wait before the task is run. The task run begins only after the specified time is elapsed.
    EnqueueableSpecify whether you want to ignore the next run command or run it after the current task. Select one of the following options:
    • False: Ignores the next run command when a particular task is already running. This is the default selection.
    • True: Starts the next run command immediately after the current running task is completed.

  3. Click Save.
    The ETL tasks page shows the details of the newly configured GCP Billing and Usage ETL.

Step III. Run the 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:

  1. In the TrueSight Capacity Optimization console, navigate to Administration ETL & System Tasks, and select ETL tasks.
  2. On the ETL tasks page, click the ETL. The ETL details are displayed.



  3. In the Run configurations table, click Edit  to modify the ETL configuration settings.
  4. On the Run configuration tab, ensure that the Execute in simulation mode option is set to Yes, and click Save.
  5. Click Run active configuration. A confirmation message about the ETL run job submission is displayed.
  6. 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.
  7.  If the ETL run status is Warning, Error, or Failed:
    1. On the ETL tasks page, click  in the last column of the ETL name row.
    2. Check the log and reconfigure the ETL if required.
    3. Run the ETL again.
    4. 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

  1. On the ETL tasks page, click the ETL. The ETL details are displayed.
  2. In the Run configurations table, click Edit  to modify the ETL configuration settings. The Edit run configuration page is displayed.
  3. On the Run configuration tab, select No for the Execute in simulation mode option, and click Save.
  4. 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:

  1. On the ETL tasks page, click the ETL, and click Edit. The ETL details are displayed.

  2. 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.
  3. 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.

Step IV. Verify data collection

Verify that the ETL ran successfully and the GCP cost data is refreshed in the TrueSight console.

To verify whether the ETL ran successfully:

  1. In the TrueSight Capacity Optimization console, click Administration > ETL and System Tasks > ETL tasks.
  2. 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:

  1. Log in to the TrueSight console.
  2. Click Cloud Cost Control, and verify whether the GCP cost data is refreshed.

Related topics

Working with ETLs Open link

Google Cloud Platform documentation Open link

Was this page helpful? Yes No Submitting... Thank you

Comments