# GCP

### Export Cloud Billing data to BigQuery

Google Cloud Platform provides a service called "BigQuery" which enables to export detailed Google Cloud billing data to a Bigquery dataset.

#### a. Create Billing Account

1. Log into GCP console portal(<https://console.cloud.google.com/>) and it will navigate to OverView Tab.

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2FgWog7GYThrKa3jC1dygX%2Fimage.png?alt=media&#x26;token=9e3b1c86-f4df-4bd7-a12b-493e4be62d06" alt=""><figcaption><p>Google Cloud Platform</p></figcaption></figure>

2. At the top left corner, find an option to create a Project which helps to monitor multiple Billing Account. Select either an already existing project or create new as needed.

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2FZ6g82eRSScjVjgIM476A%2Fimage.png?alt=media&#x26;token=65a25d47-126c-4edb-8d01-851706f93931" alt=""><figcaption><p>Create New Project</p></figcaption></figure>

3. Give a friendly Project name and create the Project.

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2FI8Uo5dVuebFMZh4EXMUi%2Fimage.png?alt=media&#x26;token=a55f451c-5eb0-42ea-b878-8b1c17fd2fe3" alt=""><figcaption><p>Google Project Creation</p></figcaption></figure>

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2F4z1DCn6HXNEIFfbqwR0y%2Fimage.png?alt=media&#x26;token=f59f2ee4-6bef-4560-bc64-c96780b6a779" alt=""><figcaption><p>Project Dashboard</p></figcaption></figure>

4. Once Project is created, navigate to "IAM & Actions" -> "Service Accounts" found at the top left corner navigation options.

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2FsVrBWlnfOSIcMaHYQ8QK%2Fimage.png?alt=media&#x26;token=eecbb079-dc5e-45d4-8208-a9fbd0a5632e" alt=""><figcaption><p>Navigate to Billing Account Tab</p></figcaption></figure>

5. On navigating to Service Account page, you will find a list of Billing Accounts monitored under the single Project.

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2F5DaEt9Bkk3uMJNEi7WXk%2Fimage.png?alt=media&#x26;token=15779b8f-6c92-41d6-bd04-85d107b8c65f" alt=""><figcaption><p>Billing Account Tab</p></figcaption></figure>

6. Create new Billing Account (Service Account).
7. Give a friendly name for the service account and create it.

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2FxIKiB32jRouCnGjtbOWl%2Fimage.png?alt=media&#x26;token=157950a8-4de3-4a63-998a-d390dd86ae34" alt=""><figcaption><p>Create Billing Account</p></figcaption></figure>

8. To have access to a more comprehensive set of Google Cloud billing data for the analysis needs, it is recommend to enable Cloud Billing data export to BigQuery at the same time as Billing Account creation.
9. Navigate to "BigQuery" -> "Data Transfers" at the navigation bar.

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2F048HAZICUktAAxUBXGBB%2Fimage.png?alt=media&#x26;token=612240a9-075b-4d1a-b700-5b4e299217a9" alt=""><figcaption><p>Navigating to Data Transfer</p></figcaption></figure>

10. Enable the Bigquery Data Transfer to access the bigquery SQL Workspace to get the cost export data.

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2F6bxFAX0XICWaUsxIe0sp%2Fimage.png?alt=media&#x26;token=1852fcfc-24b6-4e43-8048-0f5ce461ec18" alt=""><figcaption><p>Enable Big Query data Transfer</p></figcaption></figure>

### Creating a GCP Connection

To create a new connection, follow these steps:

1. Log in to Hybr Admin portal and navigate to Reporting → Data Source -> Connections page.

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2Fzi7Gdc6YMXT270w1XhAS%2Fimage.png?alt=media&#x26;token=42362145-4687-4020-9b5e-1df96b651f9c" alt=""><figcaption><p>Reporting -> Data Sources -> Connections</p></figcaption></figure>

2. List of connection created will be listed in Connection tab.
3. Create a GCP Connection using Create Connection button.

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2FI3Hg2dyuo5F1cu66n8RJ%2Fimage.png?alt=media&#x26;token=bd10fa94-afa4-449c-8b78-1a8cb3e51e74" alt=""><figcaption><p>Create GCP Connection - Step 1</p></figcaption></figure>

4. Select Connection category as "GCP".
5. Give a friendly connection name to the GCP connection.

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2FmBumvqUwStwAN72FF3kl%2Fimage.png?alt=media&#x26;token=97382194-44c9-4720-9917-aa114bde6ee6" alt=""><figcaption><p>Create GCP Connection - Step 2(a)</p></figcaption></figure>

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2F29Ogohq5sXMFBQpQdkx0%2Fimage.png?alt=media&#x26;token=bc540e3f-470c-4a75-aea7-5a1087164d3c" alt=""><figcaption><p>Create Gcp Connection - Step 2(b)</p></figcaption></figure>

6. Provide necessary connection details asked in the second step for Gcp Connection Creation.

| Parameter                         | Description                                                                                                                        |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| Connection Type                   | Specifies the type of the configuration file, which should be set to "service\_account" for a GCP service account.                 |
| Access Key Id                     | Specifies the ID of the private key associated with the service account.                                                           |
| Access Key Secret                 | Specifies the private key contents associated with the service account, which is used for authentication.                          |
| Billing Account Id                | Specifies the "Id" of the billing account created in the GCP project.                                                              |
| Billing Account Name              | Specifies the "Name" of the billing account created in the GCP project                                                             |
| Project Id                        | Specifies the ID of the GCP project where the service account is created.                                                          |
| Dataset Id                        | Specifies to a unique identifier that is used to identify and manage datasets in various GCP services                              |
| Client Id                         | Specifies the client ID associated with the service account.                                                                       |
| Client Email                      | Specifies the email address associated with the service account, which is used for authentication.                                 |
| Token URL                         | Specifies the URL for the token endpoint used for exchanging authorization codes for access tokens.                                |
| Service Account Impersonation URL | Specifies the URL where the x509 public certificates can be retrieved for the service account, which is used for token validation. |

6. Configure the Cost export start date, which ensures from when the cost export records should be collected for individual connection.
7. Save the changes.

### Editing a GCP Connection

If you want to make changes to an existing connection, follow these steps.

1. Log in to Hybr Admin portal and navigate to Reporting → Data Sources -> Connections page.
2. Select the connection and click on the "Edit" button&#x20;

<figure><img src="https://2861565768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8yyZBiQiKX8E79qF6MQC%2Fuploads%2Famznk3LzpBYQ5KAE31gx%2Fimage.png?alt=media&#x26;token=2b1d572e-9c93-484e-abbe-444b2079090e" alt=""><figcaption><p>Edit Connection</p></figcaption></figure>

3. Make the desired changes to your connection.
4. Save your changes.
