Este contenido no está disponible en el idioma seleccionado.
Integrating Google Cloud data into hybrid committed spend
Learn how to add and configure your Google Cloud integrations
Abstract
Part I. Choosing a basic or advanced Google Cloud integration Copiar enlaceEnlace copiado en el portapapeles!
To create an Google Cloud integration, first decide if you want to take a basic or advanced integration path.
Basic
For the basic option, go to Creating a Google Cloud integration: Basic.
The basic path enables cost management to directly read your billing reports from GCP at a scope that you indicate.
Advanced
For the advanced option, go to Creating a Google Cloud integration: Advanced.
The advanced path enables you to customize or filter your data before cost management reads it. You might also use the advanced path if you want to share billing data only to certain Red Hat products. The advanced path has more complex setup and configuration.
You must select either basic or advanced, you cannot choose both.
Chapter 1. Creating a Google Cloud integration: Basic Copiar enlaceEnlace copiado en el portapapeles!
You must create a Google cloud integration for hybrid committed spend from the Integrations page and configure your Google Cloud account to allow hybrid committed spend access.
If you want to create a GCP integration by using the advanced path, do not complete the following steps. Instead, go to Creating a Google Cloud integration: Advanced.
You must have a Red Hat account user with Cloud Administrator permissions before you can add integrations to hybrid committed spend.
To create a Google Cloud integration, you will complete the following tasks:
- Create a Google Cloud project for your hybrid committed spend data.
- Create a bucket for filtered reports.
- Have a billing service account member with the correct role to export your data to hybrid committed spend.
- Create a BigQuery dataset to contain the cost data.
- Create a billing export that sends the hybrid committed spend data to your BigQuery dataset.
Google Cloud is a third-party product and its console and documentation can change. The instructions for configuring the third-party integrations are correct at the time of publishing. For the most up-to-date information, see the Google Cloud Platform documentation.
1.1. Adding your Google Cloud account as an integration Copiar enlaceEnlace copiado en el portapapeles!
You can add your Google Cloud account as an integration. After adding a Google Cloud integration, the hybrid committed spend application processes the cost and usage data from your Google Cloud account and makes it viewable.
Prerequisites
- To add data integrations to cost management, you must have a Red Hat account with Cloud Administrator permissions.
Procedure
-
From Red Hat Hybrid Cloud Console, click Settings Menu
> Integrations.
- On the Settings page, in the Cloud tab, click Add integration.
- In the Add a cloud integration wizard, select Google Cloud as the cloud provider type and click Next.
- Enter a name for your integration. Click Next.
- In the Select application step, select Hybrid committed spend and click Next.
1.2. Creating a Google Cloud project Copiar enlaceEnlace copiado en el portapapeles!
Create a Google Cloud project to gather and send your cost reports to Red Hat.
Prerequisites
-
Access to Google Cloud Console with
resourcemanager.projects.createpermission
Procedure
- In the Google Cloud Console click → .
- Enter a Project name in the new page that appears and select your billing account.
- Select the Organization.
- Enter the parent organization in the Location box.
- Click .
In cost management:
- On the Project page, enter your Project ID.
- To send the default data to Red Hat automatically, select I am OK with sending the default data set to hybrid committed spend.
- Click Next.
1.3. Creating a Google Cloud Identity and Access Management role Copiar enlaceEnlace copiado en el portapapeles!
A custom Identity and Access Management (IAM) role for hybrid committed spend gives access to specific cost related resources required to enable a Google Cloud Platform integration and prohibits access to other resources.
Prerequisites
Access to Google Cloud Console with these permissions:
-
resourcemanager.projects.get -
resourcemanager.projects.getIamPolicy -
resourcemanager.projects.setIamPolicy
-
- Google Cloud project
Procedure
- In the Google Cloud Console, click → .
- Select the project you created from the menu.
- Click .
-
Enter a Title, Description and ID for the role. In this example, use
customer-data-role. - Click .
Use the Enter property name or value field to search and select the following permissions for your custom role:
-
bigquery.jobs.create -
bigquery.tables.getData -
bigquery.tables.get -
bigquery.tables.list
-
- Click .
- Click .
- In the Add a cloud integration wizard, on the Create IAM role page, click Next.
1.4. Adding a billing service account member to your Google Cloud project Copiar enlaceEnlace copiado en el portapapeles!
You must create a billing service account member that can export cost reports to Red Hat Hybrid Cloud Console in your project.
Prerequisites
In the Google Cloud Console:
- Click → .
- Select the project you created from the menu.
- Click .
Paste the following principal into the New principals field:
billing-export@red-hat-cost-management.iam.gserviceaccount.com-
In the Assign roles section, assign the IAM role you created in Creating a Google Cloud Identity and Access Management role . In this example, use
customer-data-role. - Click .
In the cost management:
- On the Assign access page, click Next.
Verification steps
- Navigate to → .
- Verify the new member is present with the correct role.
1.5. Creating a Google Cloud BigQuery dataset Copiar enlaceEnlace copiado en el portapapeles!
Create a BigQuery dataset to collect and store the billing data for hybrid committed spend.
Prerequisites
-
Access to Google Cloud Console with
bigquery.datasets.createpermission - Google Cloud project
Procedure
- In Google Cloud Console, click .
- In the Explorer panel, select the project you created.
- Click the action icon for your project name.
- Click .
-
Enter a name for your dataset in the Dataset ID field. In this example, use
CustomerData. - Click .
- In the Add a cloud integration wizard, on the Create dataset page, enter the name of the dataset you created.
- Click Next.
1.6. Exporting Google Cloud billing data to BigQuery Copiar enlaceEnlace copiado en el portapapeles!
Enabling a billing export to BigQuery sends your Google Cloud billing data (such as usage, cost estimates, and pricing data) automatically to the BigQuery dataset you created in the last step.
Prerequisites
- Access to Google Cloud Console with the Billing Account Administrator role
- Google Cloud project
- Billing service member with the cost management Identity and Access Management (IAM) role
- BigQuery dataset
Procedure
- In the Google Cloud Console, click → .
- Click the Billing export tab.
- Click in the Detailed usage cost section.
- Select the hybrid committed spend Project and Billing export dataset you created in the dropdown menus.
- Click .
- In the Add a cloud integration wizard, on the Billing export page, click Next.
- On the Review details page, review the information about your integration and click Add.
Verification steps
- Verify a checkmark with Enabled in the Detailed usage cost section, with correct Project name and Dataset name.
Chapter 2. Creating a Google Cloud integration: Advanced Copiar enlaceEnlace copiado en el portapapeles!
Create a Google Cloud function script that can filter your billing data, store it in object storage, and send the filtered reports to hybrid committed spend.
If you created an Azure integration by using the basic path, do not complete the following steps. Your Azure integration is already complete.
You must have a Red Hat account user with Cloud Administrator permissions before you can add integrations to hybrid committed spend.
To create a Google Cloud integration, you will complete the following tasks:
- Create a Google Cloud project for your hybrid committed spend data.
- Create a bucket for filtered reports.
- Create a billing service account member with the correct role to export your data to hybrid committed spend.
- Create a BigQuery dataset that contains the cost data.
- Create a billing export that sends the hybrid committed spend data to your BigQuery dataset.
Google Cloud is a third-party product and its console and documentation can change. The instructions for configuring the third-party integrations are correct at the time of publishing. For the most up-to-date information, see the Google Cloud Platform documentation.
2.1. Adding your Google Cloud account as an integration Copiar enlaceEnlace copiado en el portapapeles!
You can add your Google Cloud account as an integration. After adding a Google Cloud integration, the hybrid committed spend application processes the cost and usage data from your Google Cloud account and makes it viewable.
Prerequisites
- To add data integrations to cost management, you must have a Red Hat account with Cloud Administrator permissions.
Procedure
-
From Red Hat Hybrid Cloud Console, click Settings Menu
> Integrations.
- On the Settings page, in the Cloud tab, click Add integration.
- In the Add a cloud integration wizard, select Google Cloud as the cloud provider type and click Next.
- Enter a name for your integration. Click Next.
- In the Select application step, select Hybrid committed spend and click Next.
2.2. Creating a Google Cloud project Copiar enlaceEnlace copiado en el portapapeles!
Create a Google Cloud project to gather and send your cost reports to Red Hat.
Prerequisites
-
Access to Google Cloud Console with
resourcemanager.projects.createpermission
Procedure
- In the Google Cloud Console click → .
- Enter a Project name in the new page that appears and select your billing account.
- Select the Organization.
- Enter the parent organization in the Location box.
- Click .
In cost management:
- On the Project page, enter your Project ID.
- To configure Google Cloud to filter your data before it sends the data to Red Hat, select I wish to manually customize the data set sent to hybrid committed spend.
- Click Next.
2.3. Creating a Google Cloud bucket Copiar enlaceEnlace copiado en el portapapeles!
Create a bucket for filtered reports that you will create later. Buckets are containers that store data.
In the Google Cloud Console:
- Go to → .
- Click Create.
-
Enter your bucket information. Name your bucket. In this example, use
customer-data. - Click Create, then click Confirm in the confirmation dialog.
In cost management:
- On the Create cloud storage bucket page, enter your Cloud storage bucket name.
2.4. Creating a Google Cloud Identity and Access Management role Copiar enlaceEnlace copiado en el portapapeles!
A custom Identity and Access Management (IAM) role for hybrid committed spend gives access to specific cost related resources required to enable a Google Cloud Platform integration and prohibits access to other resources.
Prerequisites
Access to Google Cloud Console with these permissions:
-
resourcemanager.projects.get -
resourcemanager.projects.getIamPolicy -
resourcemanager.projects.setIamPolicy
-
- Google Cloud project
Procedure
- In the Google Cloud Console, click → .
- Select the project you created from the menu.
- Click .
-
Enter a Title, Description and ID for the role. In this example, use
customer-data-role. - Click .
Use the Enter property name or value field to search and select the following permissions for your custom role:
-
storage.objects.get -
storage.objects.list -
storage.buckets.get
-
- Click .
- Click .
- In the Add a cloud integration wizard, on the Create IAM role page, click Next.
2.5. Adding a billing service account member to your Google Cloud project Copiar enlaceEnlace copiado en el portapapeles!
You must create a billing service account member that can export cost reports to Red Hat Hybrid Cloud Console in your project.
Prerequisites
In the Google Cloud Console:
- Click → .
- Select the project you created from the menu.
- Click .
Paste the following principal into the New principals field:
billing-export@red-hat-cost-management.iam.gserviceaccount.com-
In the Assign roles section, assign the IAM role you created in Creating a Google Cloud Identity and Access Management role . In this example, use
customer-data-role. - Click .
In the cost management:
- On the Assign access page, click Next.
Verification steps
- Navigate to → .
- Verify the new member is present with the correct role.
2.6. Creating a Google Cloud BigQuery dataset Copiar enlaceEnlace copiado en el portapapeles!
Create a BigQuery dataset to collect and store the billing data for hybrid committed spend.
Prerequisites
-
Access to Google Cloud Console with
bigquery.datasets.createpermission - Google Cloud project
Procedure
- In Google Cloud Console, click .
- In the Explorer panel, select the project you created.
- Click the action icon for your project name.
- Click .
-
Enter a name for your dataset in the Dataset ID field. In this example, use
CustomerFilteredData. - Click .
- In the Add a cloud integration wizard, on the Create dataset page, enter the name of the dataset you created.
- Click Next.
2.7. Exporting Google Cloud billing data to BigQuery Copiar enlaceEnlace copiado en el portapapeles!
Enabling a billing export to BigQuery sends your Google Cloud billing data (such as usage, cost estimates, and pricing data) automatically to the BigQuery dataset you created in the last step.
Prerequisites
- Access to Google Cloud Console with the Billing Account Administrator role
- Google Cloud project
- Billing service member with the cost management Identity and Access Management (IAM) role
- BigQuery dataset
Procedure
- In the Google Cloud Console, click → .
- Click the Billing export tab.
- Click in the Detailed usage cost section.
- Select the hybrid committed spend Project and Billing export dataset you created in the dropdown menus.
- Click .
- In the Add a cloud integration wizard, on the Billing export page, click Next.
- On the Review details page, review the information about your integration and click Add.
-
Copy your
source_uuidso that you can use it in the cloud function.
Verification steps
- Verify a checkmark with Enabled in the Detailed usage cost section, with correct Project name and Dataset name.
2.8. Creating a function to post filtered data to your storage bucket Copiar enlaceEnlace copiado en el portapapeles!
Create a function that filters your data and adds it to the storage account that you created to share with Red Hat. You can use the example Python script to gather the cost data from your cost exports related to your Red Hat expenses and add it to the storage account. This script filters the cost data you created with BigQuery, removes non-Red Hat information, then creates .csv files, stores them in the bucket you created, and sends the data to Red Hat.
Prerequisites
- You must have a Red Hat Hybrid Cloud Console service account.
- You must have enabled the API service in GCP.
In the Google Cloud Console:
- Click → to set up a secret to authenticate your function with Red Hat without storing your credentials in your function. Enable the Secret Manager if it is not already enabled.
From Secret Manager, click Create secret.
- Name your secret, add your service account Client ID, and click Create Secret.
- Repeat this process to save a secret for your service account Client secret.
-
In the Google Cloud Console search bar, search for
functionsand select the Cloud Functions result. - On the Cloud Functions page, click Create function.
-
Name the function. In this example, use
customer-data-function. - In the Trigger section, select HTTPS as the trigger type.
In Runtime, build, connections and security settings, click the Security and image repo tab.
- Click Add a secret reference.
-
Select the
client_idsecret you created before. - Set the reference method to Exposed as environment variable.
-
Name the exposed environment variable
client_id. - Click Done.
-
Repeat the previous steps for your
client_secret. - Click Next.
- On the Cloud Functions Code page, set the runtime to the latest Python version available.
Open the requirements.txt file. Paste the following lines at the end of the file.
requests google-cloud-bigquery google-cloud-storage-
Set the Entry Point to
get_filtered_data. Open the
main.pyfile.Paste the following python script. Change the values in the section marked
# Required vars to updateto the values for your environment. Update the values for the following lines:INTEGRATION_ID- Cost management integration_id
BUCKET- Filtered data GCP Bucket
PROJECT_ID- Your project ID
DATASET- Your dataset name
TABLE_ID- Your table ID
- Click Deploy.
2.9. Trigger your function to post filtered data to your storage bucket Copiar enlaceEnlace copiado en el portapapeles!
Create a scheduler job to run the function you created to send filtered data to Red Hat on a schedule.
Procedure
Copy the Trigger URL for the function you created to post the cost reports. You will need to add it to the Google Cloud Scheduler.
-
In the Google Cloud Console, search for
functionsand select the Cloud Functions result. - On the Cloud Functions page, select your function, and click the Trigger tab.
- In the HTTP section, click Copy to clipboard.
-
In the Google Cloud Console, search for
-
Create the scheduler job. In the Google Cloud Console, search for
cloud schedulerand select the Cloud Scheduler result. Click Create job.
-
Name your scheduler job. In this example, use
CustomerFilteredDataSchedule. -
In the Frequency field, set the cron expression for when you want the function to run. In this example, use
0 9 * * *to run the function daily at 9 AM. - Set the time zone and click Continue.
-
Name your scheduler job. In this example, use
Configure the execution on the next page.
- In the Target type field, select HTTP.
- In the URL field, paste the Trigger URL you copied.
In the body field, paste the following code that passes into the function to trigger it.
{"name": "Scheduler"}- In the Auth header field, select Add OIDC token.
- Click the Service account field and click Create to create a service account and role for the scheduler job.
In the Service account details step, name your service account. In this example, use
scheduler-service-account. Accept the default Service account ID and click Create and Continue.- In the Grant this service account access to project field, search for and select Cloud Scheduler Job Runner as the first role.
- Click ADD ANOTHER ROLE, then search for and select Cloud Functions Invoker.
- Click Continue.
- Click Done to finish creating the service account.
- Go back to the Cloud scheduler tab.
- In the Configure the execution page, select the Service account field.
- Refresh the page and select the scheduler you just created.
- Click Continue and then click Create.
After completing these steps, you have successfully set up your Google Cloud function to send reports to Red Hat. For next steps, refer to Chapter 3, Next steps for managing your costs.
2.10. Creating additional cloud functions to collect finalized data Copiar enlaceEnlace copiado en el portapapeles!
At the beginning of the month, Google Cloud finalizes the bill for the month before. Create an additional function and scheduled job to trigger it to send these reports to Red Hat so cost management can process them.
Procedure
Set up a function to post reports:
- From Cloud Functions, select Create function.
- Name your function.
- Select HTTP trigger.
In Runtime, build, connections, security settings, click Security.
- Click Reference secret.
- Select Exposed as environment variable.
- Select Secret version or Latest.
- Click Done.
- Repeat the process for your other secrets.
- Click Save.
- Copy your Trigger URL. Click Next.
- Select the latest Python runtime.
-
Set Entry point to
get_filtered_data. -
Add your Google Cloud function. Update the values for
INTEGRATION_ID,BUCKET,PROJECT_ID,DATASET, andTABLE_ID. Remove the comments from the following lines:
# month_end = now.replace(day=1) - timedelta(days=1) # delta = now.replace(day=1) - timedelta(days=query_range) # year = month_end.strftime("%Y") # month = month_end.strftime("%m") # day = month_end.strftime("%d")-
Select the
requirements.pyfile and add the requirements from the requirements.txt file. - Click Deploy.
Set up a cloud scheduler to trigger your function:
- Go to Cloud Scheduler.
- Click Schedule a job.
- Name your schedule
-
Set the frequency. For example, the following cron will run the job on the fourth day of every month,
0 9 4 * * - Set a Time zone.
- Click Continue.
- Paste the function Trigger URL you copied earlier.
-
In the request body, add
{"name": "Scheduler"}. - Set the auth header to OIDC token.
- Select or create a service account with the Cloud Scheudler Job Runner and Cloud Functions Invoker roles.
- Click Continue.
- Click Save.
Providing feedback on Red Hat documentation Copiar enlaceEnlace copiado en el portapapeles!
We appreciate and prioritize your feedback regarding our documentation. Provide as much detail as possible, so that your request can be quickly addressed.
Prerequisites
- You are logged in to the Red Hat Customer Portal.
Procedure
To provide feedback, perform the following steps:
- Click the following link: Create Issue.
- Describe the issue or enhancement in the Summary text box.
- Provide details about the issue or requested enhancement in the Description text box.
- Type your name in the Reporter text box.
- Click the Create button.
This action creates a documentation ticket and routes it to the appropriate documentation team. Thank you for taking the time to provide feedback.