Configuring the **Observability Analytics** page to run your log 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 checks your Logging permissions. The
BigQuery engine checks your BigQuery permissions
instead. Both query engines let you query observability views, views on log
buckets, and analytics views.

To learn more, see
[Choose your Observability Analytics query engine](https://docs.cloud.google.com/logging/docs/analyze/data-security-with-analytics.md.txt#choose-engine).

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

   - [Logs Viewer](https://docs.cloud.google.com/iam/docs/roles-permissions/logging.md.txt#logging.viewer) (`roles/logging.viewer`) on the project
   - [Logs View Accessor](https://docs.cloud.google.com/iam/docs/roles-permissions/logging.md.txt#logging.viewAccessor) (`roles/logging.viewAccessor`) on the project or on the view that you want to query
   - [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/logging/docs/analyze/query-linked-dataset.md.txt) on your log bucket. If the dataset doesn't exist, then create it.

If you plan to configure the **Observability Analytics** page to run queries on the
BigQuery engine in projects that use
Virtual Private Cloud (VPC) Service Controls,
then verify that you're using the Enterprise Edition of BigQuery.
For more information, see
[Understand BigQuery editions](https://docs.cloud.google.com/bigquery/docs/editions-intro.md.txt).

## Run Observability Analytics queries on the BigQuery engine

When you want to
[monitor the results of your SQL query with an alerting policy](https://docs.cloud.google.com/logging/docs/analyze/sql-in-alerting.md.txt),
run your queries on the BigQuery engine by doing 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. In the **Log views** list, find the view, and then select **Query** or
   enter a query.

   If the query pane displays an error message that references the
   `FROM` statement, then the table can't be resolved to a specific log view.
   For information about how to resolve this failure, see
   [Error `FROM clause must contain exactly one log view`](https://docs.cloud.google.com/logging/docs/analyze/troubleshoot.md.txt#bad-table-name).
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**.

   If the **Run on BigQuery** button is disabled, then you
   need to create a linked dataset.
4. Run your query.

   You can use the toolbar options to format your query, clear the query,
   and open the BigQuery SQL reference documentation.

## 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/logging/docs/analyze/sql-in-alerting.md.txt)
- [Save and share a SQL query](https://docs.cloud.google.com/logging/docs/analyze/save-share-query.md.txt)
- [Sample SQL queries](https://docs.cloud.google.com/logging/docs/analyze/examples.md.txt)
- [Chart SQL query results](https://docs.cloud.google.com/logging/docs/analyze/charts.md.txt)