Create, query, and manage analytics views

This document describes how to create and manage analytics views. After you create an analytics view, you can query it in a manner similar to querying log views. If you aren't familiar with analytics views, then see About analytics views.

Before you begin

  1. Verify that billing is enabled for your Google Cloud project.

  2. To get the permissions that you need to create, manage, and use analytics views, ask your administrator to grant you the following IAM roles on your project:

    You can restrict a principal to a specific log view either by adding an IAM condition to the Logs View Accessor role grant made at the project level, or by adding an IAM binding to the policy file of the log view. For more information, see Control access to a log view.

    For information about additional roles that you need to query views on user-defined buckets or to query the _AllLogs view of the _Default log bucket, see Cloud Logging roles.

  3. Make sure that you have a log bucket that is upgraded to use Log Analytics. For information about this step, see Configure log buckets.

Create an analytics view

To create an analytics view, do the following:

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

    Go to Log Analytics

    If you use the search bar to find this page, then select the result whose subheading is Logging.

  2. Configure the Log Analytics page:
    1. Make sure that the toolbar displays Run query. If the toolbar displays Run in BigQuery, then click Settings and select Log Analytics (default).
    2. If the Views menu isn't shown, then go to the navigation pane and click Views and Schema.

  3. Enter and validate the query that you want to save as an analytics view.

    You might want to load and edit the default query for the log view that your analytics view will query. To load the default query, do the following:

    1. In the Views menu, go to the Logs section, find and then select the log view that you want to query.

    2. In the Schema toolbar, click Query, and then click Overwrite.

      The Query pane is updated with a SQL query.

    3. Update the query until you're satisfied with the query results.

  4. Create an analytics view:

    1. In the toolbar, click Save, and then select Save as analytics view.

    2. Enter a name and description for the analytics view.

      The name is limited to 100 characters and can include only letters, digits, underscores, and hyphens.. You can't change the name after you create the analytics view.

    3. Click Save.

    The system creates your analytics view and lists it in the Views pane, in the Analytics Views section.

Query an analytics view

You query an analytics view in a manner analogous to querying log views. To query analytics views , use the following format for the FROM clause:

FROM `analytics_view.PROJECT_ID.LOCATION.ANALYTICS_VIEW_ID`

The fields in the previous expressions have the following meaning:

  • PROJECT_ID: The identifier of the project.
  • LOCATION: The location of the analytics view.
  • ANALYTICS_VIEW_ID: The ID of the analytics view, which is limited to 100 characters and can include only letters, digits, underscores, and hyphens.

To learn more, see Query and analyze logs overview..

List analytics views

To list the analytics views in your Google Cloud project, do the following:

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

    Go to Log Analytics

    If you use the search bar to find this page, then select the result whose subheading is Logging.

  2. Configure the Log Analytics page:
    1. Make sure that the toolbar displays Run query. If the toolbar displays Run in BigQuery, then click Settings and select Log Analytics (default).
    2. If the Views menu isn't shown, then go to the navigation pane and click Views and Schema.

  3. In the Views menu, go to the Analytics Views section.

Get details about an analytics views

You can use options in the Schema pane to display the following information about an analytics view:

  • Name.
  • Create date.
  • Last update.
  • Schema.
  • Query.

To view the details for an analytics views, list the analytics views in your project, and then do the following:

  1. Select the analytics view whose information you want to view.
  2. In the Schema toolbar click View analytics view options, and select View details.

Modify an analytics view

To modify an analytics view, do the following:

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

    Go to Log Analytics

    If you use the search bar to find this page, then select the result whose subheading is Logging.

  2. Configure the Log Analytics page:
    1. Make sure that the toolbar displays Run query. If the toolbar displays Run in BigQuery, then click Settings and select Log Analytics (default).
    2. If the Views menu isn't shown, then go to the navigation pane and click Views and Schema.

  3. In the Views menu, go to the Analytics Views section, and select the analytics view that you want to modify.
  4. In the Schema toolbar, click View analytics view options, and select Edit view.

    A dialog opens that displays information about the analytics view. You can modify the description and query.

  5. After you complete your modifications, click Overwrite saved view.

Delete an analytics view

To delete an analytics view, do the following:

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

    Go to Log Analytics

    If you use the search bar to find this page, then select the result whose subheading is Logging.

  2. Configure the Log Analytics page:
    1. Make sure that the toolbar displays Run query. If the toolbar displays Run in BigQuery, then click Settings and select Log Analytics (default).
    2. If the Views menu isn't shown, then go to the navigation pane and click Views and Schema.

  3. In the Views menu, go to the Analytics Views section, and select the analytics view that you want to delete.
  4. In the Schema toolbar, click View analytics view options, select Delete view, and complete the dialog.

Limitations

The following limitations apply to analytics views:

  • An analytics view can only query log views.
  • The parent resource of an analytics view must be a Google Cloud project.
  • You can only query an analytics view by using the Log Analytics page, and only when you use the Log Analytics (default) query engine.
  • All views that an analytics view queries must be in the same location.
  • You must use the Google Cloud console to create or manage your analytics views.
  • You can create at most 100 analytics views per Google Cloud project.
  • You can create a most 50 analytics views per region.
  • Per Google Cloud project, at most 10 regions can contain an analytics view.

What's next