> For the complete documentation index, see [llms.txt](https://docs.onelens.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.onelens.cloud/integrations/cloud-and-cost-sources/connecting-to-gcp/manual.md).

# Manual

{% hint style="info" %}
The user performing the integration must have the following roles assigned:

1\. **Owner** on your projects/folders to be onboarded\
2\. **Organisation Administrator** on your organisation\
\
**Why this is needed?**\
Organisation Administrator role is used to create a new billing project and to assign the organisation-level IAM roles to the service account & external user. Owner role is used to enable the required APIs on the projects being onboarded.
{% endhint %}

{% hint style="warning" %}
Below APIs must be enabled on your projects for OneLens to be able to read usage data on the respective services:

1. `Vertex AI API` *(aiplatform.googleapis.com)*
2. `Cloud Functions API` *(cloudfunctions.googleapis.com)*
3. `Cloud SQL Admin API` *(sqladmin.googleapis.com)*
4. `Compute Engine API` *(compute.googleapis.com)*
5. `Kubernetes Engine API` *(container.googleapis.com)*
6. `Dataflow API` *(dataflow\.googleapis.com)*
7. `Cloud Dataproc API` *(dataproc.googleapis.com)*
8. `Cloud Filestore API` *(file.googleapis.com)*
9. `Cloud Monitoring API` *(monitoring.googleapis.com)*
10. `Network Management API` *(networkmanagement.googleapis.com)*
11. `Recommender API` *(recommender.googleapis.com)*
12. `Google Cloud Memorystore for Redis API` *(redis.googleapis.com)*
13. `Service Usage API` *(serviceusage.googleapis.com)*
14. `Cloud Asset API` *(cloudasset.googleapis.com)*
15. `BigQuery API` *(bigquery.googleapis.com)*
16. `Cloud Logging API` *(logging.googleapis.com)*
17. `Cloud Storage API` *(storage.googleapis.com)*

\
The above APIs must be enabled for ***each*** project to be onboarded.

For steps on how to enable APIs, please follow this link to Google’s [documentation](https://cloud.google.com/apis/docs/getting-started#enabling_apis).
{% endhint %}

{% stepper %}
{% step %}

### Create the Billing Project

* Login to the Google Cloud Platform console.
* In the `Project Picker` menu on top, create a project with the name “*OneLens Billing Project*”.

  <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FM083vVUkCnf44vD1OZ2O%2FScreenshot%202025-10-16%20at%204.41.06%20AM.png?alt=media&#x26;token=0f04e17c-da82-409c-a979-71c1c80a0e01" alt=""><figcaption></figcaption></figure>
* Using the `Project Picker` menu on top, open the newly created project "*OneLens Billing Project*".
* Using the search bar on top, search for and enable the `Cloud Billing API` on this project.<br>

  <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FZ6rkUuF1rrEZeiucdSjG%2FScreenshot%202025-10-31%20at%206.16.20%20PM.png?alt=media&#x26;token=00b9f953-e88d-416f-9e92-7f7c8952e6b8" alt=""><figcaption></figcaption></figure>
* In the same way, search for and enable the `API Keys API` on this project.
  {% endstep %}

{% step %}

### Enable Detailed Usage Export

* In the `Project Picker` menu on top, open the billing project created (*OneLens Billing Project*).
* In the left menu, open `BigQuery Studio`.
* In the `BigQuery Explorer` pane, click the `3 dots` to the right of the billing project ID, and click `Create dataset`.<br>

  <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FgLIe9sajWgK6oc7KXn8o%2FScreenshot%202025-10-16%20at%204.42.40%20AM.png?alt=media&#x26;token=4ce39f26-1e8f-4b05-9262-7128c423af3d" alt=""><figcaption></figcaption></figure>
* In the opened `Create dataset` menu, enter the following data:
  * Under `Dataset ID`, enter “*billing\_export*”.
  * Under `Location type`, select *Multi-region*.
  * Under `Multi-region`, select *US (multiple regions in the United States)*<br>

    <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FbfU2mK6Gal6TNNSYBcmS%2FScreenshot%202025-10-16%20at%204.44.35%20AM.png?alt=media&#x26;token=d0486f76-4305-41c7-a801-0266a1910580" alt=""><figcaption></figcaption></figure>

    <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>The dataset location is set to US (multiple regions in the United States) to export cost data retroactively from the start of the previous month during the initial setup.</p><p><br><a href="https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#data-availability">https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#data-availability</a></p></div>
  * Under `Advanced options`, make sure the `Enable table expiry` option is *unchecked*.

    <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FNEvYblKxcsDEoNlsTeFV%2FScreenshot%202025-10-16%20at%204.46.31%20AM.png?alt=media&#x26;token=edc1cfcd-ee7a-4a9a-bb85-63431bf10214" alt=""><figcaption></figcaption></figure>
  * <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>By disabling the table expiry for the BigQuery dataset, we ensure that the Single Source of Truth for your cloud costs remains intact indefinitely, enabling deep historical analysis, accurate forecasting, and audit compliance.<br><br><a href="https://docs.cloud.google.com/billing/docs/how-to/export-data-bigquery">https://docs.cloud.google.com/billing/docs/how-to/export-data-bigquery</a></p></div>
  * Click `Create data set`.
* Go to `Billing` on the left menu.
* Under `Cost management`, select `Billing export` in the left menu.
* Enable `Detailed usage cost` with the following options:
  * Under `Projects`, select the billing project created (*OneLens Billing Project)*.
  * Under `Dataset`, select the dataset created (*billing\_export*).
  * Click `Save`.<br>

    <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2Fn7fe0iDWUnwQApnquWnm%2FScreenshot%202025-10-16%20at%203.41.27%20AM.png?alt=media&#x26;token=81cde2ae-5886-4f4c-b2c6-3b7aecd15c88" alt=""><figcaption></figcaption></figure>

{% endstep %}

{% step %}

### Enable CUD Export

* Go to `Billing` on the left menu.
* Under `Cost management`, select `Billing export` in the left menu.
* Enable `Committed use discounts export` with the following options:

  * Under `Projects`, select the billing project created (*OneLens Billing Project*).
  * Under `Linked dataset name`, enter a new dataset name: *cud\_export*.
  * Under `Location type`, select *Multi-region*.
  * Under `Multi-region`, select *US (multiple regions in the United States)*.
  * Click `Save`.<br>

  <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FKK8Iwdz3G6H4FurDigx1%2Fimage.png?alt=media&#x26;token=2f5f35b0-a036-47de-b69d-2f2e410b3fd6" alt=""><figcaption></figcaption></figure>

  <div data-gb-custom-block data-tag="hint" data-style="warning" class="hint hint-warning"><p>Do not create this dataset in BigQuery Studio beforehand. The committed use discounts export requires a dataset name that does not already exist, and creates the linked dataset for you.</p></div>

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>This export writes a <code>cud_subscriptions_export</code> table holding the metadata of every committed use discount purchased in any project linked to this billing account: product, commitment amount, term and consumption model.<br></p><p>Keep it in the same location as <code>billing_export</code> so the two datasets can be queried together.</p></div>

{% endstep %}

{% step %}

### Create the Service Account and assign permissions on the Billing project

* In the `Project Picker` menu on top, select the new billing project created just now (i.e., *OneLens Billing Project*)
* Go to `IAM and admin` on the left bar.
* Go to `Service accounts` and click on `+ Create service account`.
  * Enter the `Service account name` as “*OneLens Reader SA*”
  * `Service account ID` should be automatically generated.
  * Enter the `Service account description` as: *SA used by OneLens with read-only roles for FinOps analysis*.
  * Click `Create and continue`.<br>

    <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FBcLF3b6LIAL3w07r9HAA%2FScreenshot%202025-10-31%20at%206.20.21%20PM.png?alt=media&#x26;token=2332cacf-0c65-457d-b67b-2160d894ad70" alt=""><figcaption></figcaption></figure>
* Under `Permissions`, search for and select the following roles:
  * `BigQuery Data Viewer`
  * `BigQuery Metadata Viewer`
  * `BigQuery Job User`
  * `BigQuery Read Session User`
* Click `Continue`

  <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FeHM728uL4cVpyFDLpAa6%2FScreenshot%202025-11-11%20at%203.24.37%E2%80%AFPM.png?alt=media&#x26;token=dba09365-4199-42cb-b34a-225b2ce5a3e5" alt=""><figcaption></figcaption></figure>
* Click `Done`
* On the left, under `IAM and admin`, select `Service Accounts`
* Select the service account that was created just now (i.e., *OneLens Reader SA*).
* Under the `Principals with access` tab, click `+ Grant access`.
* Under `Add principals`, enter the following values
  * `onelens-customer-sa@astuto-prod-mum.iam.gserviceaccount.com` (our backend Service Account)
  * `onelens.finops@astuto.ai` (our external user email)
* Under `Assign Roles`, add the following role:
  * `Service Account Token Creator`
* Click `Save`.

  <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FCn0WzksWmVIJLQ6WgFEJ%2FScreenshot%202025-11-17%20at%203.41.30%E2%80%AFPM.png?alt=media&#x26;token=915c3bc0-61e2-4f92-9326-54ff6d52bc0c" alt=""><figcaption></figcaption></figure>

{% endstep %}

{% step %}

### Assign Billing project roles to the External User

* In the `Project Picker` menu on top, select the new billing project created just now (i.e., *OneLens Billing Project*)
* Go to `IAM and admin` and click `+ Grant access`.
* Under `Add principals`, enter the value of the `external user email ID` provided to you by the OneLens team: `onelens.finops@astuto.ai`
* Under Assign Roles, add the following roles and click Save:
  * `BigQuery Data Viewer`
  * `BigQuery Metadata Viewer`
  * `BigQuery Job User`<br>

    <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2F8OaSJuMWw6ztHAERx0ik%2FScreenshot%202025-10-31%20at%206.47.41%20PM.png?alt=media&#x26;token=f62414f6-7733-4fc5-b483-8b011bc56a56" alt=""><figcaption></figcaption></figure>

{% endstep %}

{% step %}

### Assign Organisation-level roles for Service Account and External User

* Open the `Project Picker` menu and select your `organisation`.
* Go to `IAM and admin` and click `+ Grant access`.
* Under `Add principals`, search for and select the `service account` that was created (i.e., *OneLens Reader SA*) and the external user email (i.e., `onelens.finops@astuto.ai`)
* Under `Assign Roles`, add the following roles and click `Save`:
  * `Organisation Viewer`
  * `Cloud Asset Viewer`
  * `Browser`
  * `Billing Account Viewer`<br>

    <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FUgyeO2N1ioUu9C4AwzWc%2FScreenshot%202025-10-31%20at%206.51.32%20PM.png?alt=media&#x26;token=f220d598-cb54-4b03-b878-cac80005cbf1" alt=""><figcaption></figcaption></figure>

{% endstep %}

{% step %}

### Assign Organisation-level service roles to the Service Account

* Open the `Project Picker` menu and select your `organisation`.
* Go to `IAM and admin` and click `+ Grant access`.
* Under `Assign Roles`, add the following roles:
  * `Vertex AI Viewer`
  * `Cloud Functions Viewer`
  * `Cloud SQL Viewer`
  * `Compute Viewer`
  * `Kubernetes Engine Viewer`
  * `Dataflow Viewer`
  * `Dataproc Viewer`
  * `Cloud Filestore Viewer`
  * `Monitoring Viewer`
  * `Network Management Viewer`
  * `Recommender Viewer`
  * `Cloud Memorystore Redis Viewer`
  * `Service Usage Viewer`
  * `Logs Viewer`
  * `Storage Bucket Viewer`
  * `BigQuery Job User`
  * `BigQuery Metadata Viewer`
  * `BigQuery Resource Viewer`
* Click `Save`.<br>

  <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FyJ9qMHtjvdlhldhezfQn%2FScreenshot%202025-10-31%20at%207.10.54%20PM.png?alt=media&#x26;token=4074770d-556d-4998-b37e-74c0e5b1ed5b" alt=""><figcaption></figcaption></figure>

  <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2F0MGDy31zL7j67zYfD2w7%2FScreenshot%202025-10-31%20at%207.04.35%20PM.png?alt=media&#x26;token=ba3cbf88-e84b-494c-8aa4-f900b8e006fa" alt=""><figcaption></figcaption></figure>

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Granting at the organisation level covers every project in the organisation, including projects added later, so these steps are performed once.</p></div>

  <br>

{% hint style="info" %}
`Storage Bucket Viewer` (`roles/storage.bucketViewer`) is a Beta role in Google Cloud. It holds two permissions, `storage.buckets.get` and `storage.buckets.list`, which let OneLens read bucket names, locations, storage classes and lifecycle configuration. It gives no access to the objects inside a bucket, and it cannot read bucket IAM policies.

`Logs Viewer` (`roles/logging.viewer`) reads log entries and log-based metric metadata in the `_Required` and `_Default` log buckets. It does not cover Data Access audit logs, which require `Private Logs Viewer` (`roles/logging.privateLogViewer`), and OneLens does not ask for that role.
{% endhint %}
{% endstep %}

{% step %}

### Assign Organisation-level service roles to the External User

* Open the `Project Picker` menu and select your `organisation`.
* Go to `IAM and admin` and click `+ Grant access`.
* Under `Add principals`, enter and select the external user email (i.e., `onelens.finops@astuto.ai`).
* Under `Assign Roles`, add the following roles:
  * `Viewer`
  * `BigQuery Resource Viewer`
  * `BigQuery Metadata Viewer`
  * `BigQuery Job User`
* Click `Save`.<br>

  <figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2Ffom78qzrkzHTcL1rriIf%2FScreenshot%202025-10-31%20at%207.19.54%20PM.png?alt=media&#x26;token=ca9646eb-6985-43a3-baf5-46aba8de9cff" alt=""><figcaption></figcaption></figure>

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Granting at the organisation level covers every project in the organisation, including projects added later, so these steps are performed once.</p></div>

{% endstep %}

{% step %}

### Create and assign the AI key inventory role

OneLens reports on the API keys in your organisation, so that keys which can reach Vertex AI or Gemini without a restriction are visible alongside their cost. That needs one permission, `apikeys.keys.list`, which returns a key's name, display name, API restrictions and creation time.

* Open the `Project Picker` menu and select your `organisation`.
* Go to `IAM and admin` and select `Roles` in the left menu.
* Click `+ Create custom role` and enter the following:
  * Under `Title`, enter *OneLens AI Key Inventory*.
  * Under `Description`, enter *Lists API key metadata for OneLens AI cost reporting. Cannot read key strings.*
  * Under `ID`, enter *onelensAiKeyInventory*.
  * Click `+ Add permissions`, filter for `apikeys.keys.list`, tick it, and click `Add`.
  * Click `Create`.

<figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2Fn7Z1Atgl09DuO7C8aLT3%2Fimage.png?alt=media&#x26;token=5270c439-5b70-4de1-9038-bf5ffcd90482" alt=""><figcaption></figcaption></figure>

* Go back to `IAM and admin` and click `+ Grant access`.
* Under `Add principals`, search for and select the `service account` that was created (i.e., *OneLens Reader SA*).
* Under `Assign Roles`, add the role `OneLens AI Key Inventory` and click `Save`.

{% hint style="info" %}
This role is granted to the service account only, not to the external user.
{% endhint %}

{% hint style="info" %}
There is a predefined role for this, `API Keys Viewer`, and it is deliberately not used here. It also contains `apikeys.keys.getKeyString`, which reads live key strings. The custom role above holds `apikeys.keys.list` and nothing else, so the key strings in your organisation stay unreachable.
{% endhint %}
{% endstep %}
{% endstepper %}

{% hint style="success" %}
**You have now&#x20;**<mark style="color:$success;">**successfully**</mark>**&#x20;integrated your Google Cloud Platform environment with OneLens.**

\
**Please share the following values to the OneLens team to facilitate the connection on our end:**

* *Billing project ID*
* *Service Account email ID*
* *BigQuery dataset ID (billing\_export)*
* *BigQuery dataset ID (cud\_export)*
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.onelens.cloud/integrations/cloud-and-cost-sources/connecting-to-gcp/manual.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
