# GCP Bigquery

### Pre-Requisite <a href="#pre-requisite" id="pre-requisite"></a>

* Project in GCP
* IAM Role which has access to big query service

### Create Bigquery Forwarder <a href="#create-bigquery-forwarder" id="create-bigquery-forwarder"></a>

* Navigate to `create forwarder` page
* Select `bigquery` forwarder
* Provide the credentials for the IAM role as JSON in `json_key` field
* Provide `project_id`, `dataset_id` and `table_id`
* Set `table_expiration` in hours which will delete the table after the specified expiration time
* Enable the `create_table` toggle to define the schema for the table
* Add required columns for the table
* Provide `name` for the forwarder and click `create`

<figure><img src="/files/KpJ7fPKbm1luRQLeUUYX" alt=""><figcaption></figcaption></figure>

### Create Bigquery Forwarder with existing table <a href="#create-bigquery-forwarder-with-existing-table" id="create-bigquery-forwarder-with-existing-table"></a>

* Select `bigquery` forwarder
* Provide the credentials for the IAM role as JSON in `json_key` field
* Provide `project_id`, existing`dataset_id` and existing`table_id`
* Set `table_expiration` in hours which will delete the table after the specified expiration time
* Disable the `create_table` toggle to define the schema for the table
* Provide `name` for the forwarder and click `create`

### Add Column to Biquery Table <a href="#add-column-to-biquery-table" id="add-column-to-biquery-table"></a>

* Navigate to `forwarders` page
* Click `edit` icon in the big query forwarder for which you need to add columns in the schema
* Click on `add column` to update the schema

<figure><img src="/files/fe4Pb7gJK3NK0dGVYdWr" alt=""><figcaption></figcaption></figure>

### Mapping logs to Bigquery table <a href="#mapping-logs-to-bigquery-table" id="mapping-logs-to-bigquery-table"></a>

When you forward your logs to BigQuery, the fields in the log will be mapped to the column in the table. By default, Apica maps the schema from the forwarder to the facet in the logs. It will insert the value for the facet as a value to the column in the table.

<figure><img src="/files/4BCbSMQvxFbW6jReytfn" alt=""><figcaption><p>Facets List</p></figcaption></figure>

<figure><img src="/files/Mp7YWfLlDrn9gMjTrAXe" alt=""><figcaption><p>Columns in bigquery table</p></figcaption></figure>

To change the default mapping behavior, [create a forward rule](/flow/rules/forward.md) for the namespace and application by renaming the facet with the column name. This will help you to manage the mappings between your log and the BigQuery table schema.


---

# Agent Instructions: 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:

```
GET https://docs.apica.io/flow/list-of-forwarders/gcp-bigquery.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
