Querying your log data in BigQuery Studio lets you join logs with other
business data and use commands, workflows, and datasets available only in
BigQuery. You can open a SQL query directly in BigQuery Studio from
the **Observability Analytics** page. The query automatically formats the `FROM` clause for
your [linked BigQuery dataset](https://docs.cloud.google.com/logging/docs/analyze/query-linked-dataset.md.txt).

If you aren't familiar with Observability Analytics, then see
[Observability Analytics overview](https://docs.cloud.google.com/logging/docs/log-analytics.md.txt).

## Before you begin

1.

   To get the permissions that
   you need to query a linked dataset from BigQuery Studio,

   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 the project or on the linked BigQuery dataset
   - [BigQuery Job User](https://docs.cloud.google.com/iam/docs/roles-permissions/bigquery.md.txt#bigquery.jobUser) (`roles/bigquery.jobUser`) on the 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.

## Run queries from BigQuery Studio

To open BigQuery from the Observability Analytics page and then query your log
data, 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. In the **Log views** list, find and select the log view.

3. In the **Schema** pane, select **Query**.

   The **Query** pane is populated with a default query.
   You can also enter a query in the **Query** pane, or edit a displayed query.
4. In the toolbar, expand the button labeled **Run query** or
   **Run on BigQuery** , and select **Open in BigQuery**.

   BigQuery Studio opens. The `FROM`
   statement of the query is modified to specify the path to the log view on the
   linked dataset by using the BigQuery
   [Table path syntax](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language.md.txt#table_path).

   You can also edit the displayed query.
5. In BigQuery Studio, click **Run query**.

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