Configuring Observability Analytics to run your Cloud Trace queries on the
BigQuery engine lets you create SQL-based alerting policies and save
dashboard charts whose queries join observability data with other business data.
When queries run on the BigQuery engine, they use on-demand slots
by default, or [reserved slots](https://docs.cloud.google.com/bigquery/docs/reservations-intro.md.txt#reservations) if your project has a
reservation assignment in the same location as the linked dataset.

Unless you modify the configuration, the **Observability Analytics** page runs queries on
the default query engine, which uses default slots. Both engines let you query
observability views, views on log buckets, and analytics views.

## Before you begin

1.

   To get the permissions that
   you need to run queries from Observability Analytics using the
   BigQuery engine,

   ask your administrator to grant you the
   following IAM roles:

   - [Observability Viewer](https://docs.cloud.google.com/iam/docs/roles-permissions/observability.md.txt#observability.viewer) (`roles/observability.viewer`) on the project
   - [Observability View Accessor](https://docs.cloud.google.com/iam/docs/roles-permissions/observability.md.txt#observability.viewAccessor) (`roles/observability.viewAccessor`) on the observability views that you want to query. This role supports IAM conditions, which let you restrict the grant to a specific view. If you don't attach a condition to the role grant, then the principal can access all observability views.
   - [BigQuery Data Viewer](https://docs.cloud.google.com/iam/docs/roles-permissions/bigquery.md.txt#bigquery.dataViewer) (`roles/bigquery.dataViewer`) on your project or the linked dataset
   - [BigQuery Job User](https://docs.cloud.google.com/iam/docs/roles-permissions/bigquery.md.txt#bigquery.jobUser) (`roles/bigquery.jobUser`) on your project


   For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).


   You might also be able to get
   the required permissions through [custom
   roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles) or other [predefined
   roles](https://docs.cloud.google.com/iam/docs/roles-overview#predefined).
2. Verify that you have a [linked BigQuery dataset](https://docs.cloud.google.com/trace/docs/analytics-query-linked-dataset.md.txt) on the observability dataset that stores your trace data. If the linked BigQuery dataset doesn't exist, then create it.

If you configure the **Observability Analytics** page to use the
BigQuery engine in a Google Cloud project protected by
Virtual Private Cloud (VPC) Service Controls,
then use the Enterprise Edition of BigQuery.
For more information, see
[Understand BigQuery editions](https://docs.cloud.google.com/bigquery/docs/editions-intro.md.txt).

## Run queries on the BigQuery engine

To run a query on the BigQuery engine when using the
**Observability Analytics** page, do the following:

1. In the Google Cloud console, go to the
   **Observability Analytics** page:

   [Go to **Observability Analytics**](https://console.cloud.google.com/logs/analytics)

   <br />

   If you use the search bar to find this page, then select the result whose subheading is
   **Logging**.
2. Enter or load a query. For more information, see
   [Query and analyze traces](https://docs.cloud.google.com/trace/docs/analytics.md.txt).

   You can save a chart to a dashboard where the chart displays the result of
   a join between observability data and other business data. For this case,
   the `FROM` clause must specify either a view on an observability dataset or
   a view on a log bucket, and there must also be a linked dataset for the data
   queried. The `JOIN` statement can specify a BigQuery table.
   However, you must have the required IAM permissions to query
   the BigQuery table.
3. Go to the toolbar and verify that a button labeled **Run on BigQuery**
   is displayed.

   If the toolbar displays **Run Query** , then
   click **Settings** and select **BigQuery**.

   A disabled **Run on BigQuery** button indicates that there isn't
   a linked dataset. To resolve this failure,
   [create the linked BigQuery dataset](https://docs.cloud.google.com/trace/docs/analytics-query-linked-dataset.md.txt).
4. Click **Run on BigQuery**.

## Pricing

To learn about the costs associated with using BigQuery, see
[BigQuery pricing](https://cloud.google.com/bigquery/pricing).

## What's next

- [Monitor your SQL query results with an alerting policy](https://docs.cloud.google.com/trace/docs/sql-in-alerting.md.txt)
- [Save and share a SQL query](https://docs.cloud.google.com/trace/docs/analytics-save-share-query.md.txt)
- [Chart SQL query results](https://docs.cloud.google.com/trace/docs/analytics-chart.md.txt)
- [Sample SQL queries](https://docs.cloud.google.com/trace/docs/analytics-samples.md.txt)