> For the complete documentation index, see [llms.txt](https://docs.economize.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.economize.cloud/google-cloud/bigquery.md).

# Analyzing BigQuery costs by linking the logging export

Follow the below steps to create and integrate a logging sink with Economize, allowing you to analyze BigQuery costs within [Reports](/product-features/reports.md).

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

## Step 1: Create a Logging sink

1. Navigate to the [BigQuery console](https://console.cloud.google.com/bigquery) to create a new dataset named **logging\_export** in the same project where you created the billing export dataset during onboarding.

<img src="https://ik.imagekit.io/economize/docs/dashboard/bq-cost-breakdown/pasted_image_0_r-FVjuCSQ.png" alt="" width="563">

2. For this newly created dataset configure the permission as follows:

   * Select the three vertical dots next to the dataset name, then click **Share**.
   * On the **Share permissions** panel that appears on the right, click **+ ADD PRINCIPAL**.
   * In the **New principals** field, under **Add principals**, paste the value of the service account based on your selected access method during onboarding.
   * In the **Role** field, under **Assign roles**, search for and select **BigQuery Data Editor**.

   <img src="https://ik.imagekit.io/economize/docs/dashboard/bq-cost-breakdown/pasted_image_0-4_PGsZHDXsa05.png?ik-sdk-version=javascript-1.4.3&#x26;updatedAt=1647102434330" alt="" width="563">
3. Now go to the [Log router](https://console.cloud.google.com/logs/router) and select **Create Sink.**

<img src="https://ik.imagekit.io/economize/docs/dashboard/bq-cost-breakdown/pasted_image_0-1_G7zAB6fg_.png?ik-sdk-version=javascript-1.4.3&#x26;updatedAt=1647102433383" alt="" width="563">

4. Provide a sink name and select the BigQuery dataset **logging\_export** that you created earlier as the destination.
5. Click on the **Use partitioned tables** checkbox in the form.

<img src="https://ik.imagekit.io/economize/docs/dashboard/bq-cost-breakdown/pasted_image_0-2_DNazA4a2Z.png?ik-sdk-version=javascript-1.4.3&#x26;updatedAt=1647102433762" alt="" width="563">

6. Provide the below inclusion filter in Step 3 when asked to **Choose logs to include in sink**.

{% code title="Inclusion filter" overflow="wrap" fullWidth="false" %}

```
protoPayload.serviceName="bigquery.googleapis.com" AND protoPayload.methodName="jobservice.jobcompleted"
```

{% endcode %}

<img src="https://ik.imagekit.io/economize/docs/dashboard/bq-cost-breakdown/pasted_image_0-3_AmRGC_DCN.png?ik-sdk-version=javascript-1.4.3&#x26;updatedAt=1647102433859" alt="" width="563">

7. Leave the exclusion filter empty and click on **Create Sink**.

## Step 2: Integrate Logging sink with Economize <a href="#integrating-logging-sink" id="integrating-logging-sink"></a>

1. Navigate to the [**Projects page**](https://www.economize.cloud/app/settings/projects) from the settings of the Economize console.

<figure><img src="/files/hcM1qWsTqPdbH5iGRyEq" alt="" width="563"><figcaption></figcaption></figure>

2. Click on the pen icon for the project you wish to analyze the BigQuery costs.
3. Enter the **Dataset ID** of the BigQuery dataset you created in step 1 in the following text field.

<figure><img src="/files/aEOwDkac1Hpv1q90rALS" alt="" width="563"><figcaption></figcaption></figure>

4. Test your connection to the dataset by clicking on the test button.

<img src="https://ik.imagekit.io/economize/docs/dashboard/bq-cost-breakdown/Screenshot_2022-03-12_at_6.23.03_PM_DLdMrWAJG.png?ik-sdk-version=javascript-1.4.3&#x26;updatedAt=1647103502565" alt="" width="563">

5. Click on the **Save Changes** button.

{% hint style="success" %}
**SUCCESS**

You can now navigate to the [Reports](https://www.economize.cloud/app/gcp/reports) within the Economize console and start analyzing the BigQuery costs.
{% endhint %}
