使用 BigQuery Studio 查询轨迹数据

本文档介绍了如何从 BigQuery Studio 查询跟踪记录数据。使用 BigQuery Studio 时,您可以将跟踪记录数据与其他商家数据联接。

如需开始使用 Observability Analytics,请参阅 查询和分析跟踪记录

准备工作

  1. 登录您的 Google Cloud 账号。如果您是 Google Cloud的新用户, 请创建一个账号,以便在 真实场景中评估我们产品的性能。新客户还可以获得 300 美元的免费抵用金,用于 运行、测试和部署工作负载。
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

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

  4. Enable the Cloud Monitoring and Observability APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

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

  7. Enable the Cloud Monitoring and Observability APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  8. 如需获得从 BigQuery 查询关联数据集所需的权限,请让您的管理员为您授予项目或关联数据集的BigQuery Data Viewer (roles/bigquery.dataViewer) IAM 角色。如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限

    您也可以通过自定义 角色或其他预定义 角色来获取所需的权限。

  9. 验证是否存在名为 _Trace 的可观测性存储桶的 关联 BigQuery 数据集 。如果关联的 BigQuery 数据集不存在,请创建该数据集。

在 BigQuery Studio 上运行查询

如需从 Observability Analytics 页面打开 BigQuery,然后查询跟踪记录数据,请执行以下操作:

  1. 在 Google Cloud 控制台中,前往 Observability Analytics 页面:

    前往 Observability Analytics

    如果您使用搜索栏查找此页面,请选择子标题为 Logging 的结果。

  2. 输入或加载查询。如需了解详情,请参阅 查询和分析跟踪记录

  3. 在工具栏中,展开标有运行查询在 BigQuery 上运行的菜单,然后选择在 BigQuery 中打开

    BigQuery Studio 随即会打开。在此页面上,FROM 语句 使用 BigQuery 表路径语法指定关联的数据集。您可以对查询执行任何受支持的操作,例如对其进行修改。

    如果在 BigQuery 中打开 选项处于停用状态,则表示关联的数据集不存在,或者您没有在 BigQuery 中打开和查看查询所需的权限。

  4. 在 BigQuery Studio 上,点击运行查询

价格

如需了解使用 BigQuery 的相关费用,请参阅 BigQuery 价格

后续步骤