本文說明如何設定「可觀測性分析」頁面,在 BigQuery 引擎上執行查詢。如果警告政策是以 SQL 為基礎,您就必須在 BigQuery 引擎上執行查詢。將以 SQL 為基礎的圖表儲存至資訊主頁時,如果查詢會合併可觀測性資料和其他業務資料,也需要使用這個查詢引擎。
根據預設,Observability Analytics 頁面會在預設查詢引擎上執行查詢,該引擎會使用預設時段執行查詢。除非預留運算單元,否則 BigQuery 引擎也會在預設運算單元上執行查詢。預留時段可避免因預設時段已滿而導致查詢延遲。
無論使用預設查詢引擎或 BigQuery 引擎,您都可以查詢可觀測性檢視區塊、記錄檔儲存空間檢視區塊和分析檢視區塊。
事前準備
- 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
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 theserviceusage.services.enablepermission. Learn how to grant roles.-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
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 theserviceusage.services.enablepermission. Learn how to grant roles.-
如要取得使用 BigQuery 專屬配額,從可觀測性分析執行查詢所需的權限,請要求管理員授予您下列 IAM 角色:
- 在要查詢的觀測檢視畫面中,選取「觀測檢視畫面存取者」 (
roles/observability.viewAccessor)。這個角色支援 IAM 條件,可讓您將授權限制在特定檢視區塊。如果未將條件附加至角色授予作業,主體就能存取所有可觀測性檢視畫面。 - BigQuery 使用者 (
roles/bigquery.user) 專案 - 專案的 BigQuery 工作使用者 (
roles/bigquery.jobUser)
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
- 在要查詢的觀測檢視畫面中,選取「觀測檢視畫面存取者」 (
- 確認名為
_Trace的可觀測性值區有連結的 BigQuery 資料集。如果連結的 BigQuery 資料集不存在,請建立該資料集。
如果您打算設定「可觀測性分析」頁面,在 BigQuery 運算單元上執行查詢,且您使用的專案具有虛擬私有雲 (VPC) 服務控制項,請確認您使用的是 BigQuery Enterprise 版。詳情請參閱瞭解 BigQuery 版本。
在 BigQuery 引擎上執行查詢
使用「可觀測性分析」頁面時,如要在 BigQuery 引擎上執行查詢,請按照下列步驟操作:
-
在 Google Cloud 控制台中,前往 manage_search「Observability Analytics」(觀測能力分析) 頁面:
前往「Observability Analytics」(觀測能力分析) 頁面
如果您是使用搜尋列尋找這個頁面,請選取子標題為「Logging」的結果。
輸入或載入查詢。詳情請參閱「查詢及分析追蹤記錄」。
您可以將圖表儲存至資訊主頁,圖表會顯示可觀測性資料和其他業務資料的聯結結果。在這種情況下,
FROM子句必須指定可觀測性資料集的檢視區塊或記錄 bucket 的檢視區塊,且必須有查詢資料的連結資料集。JOIN陳述式可以指定 BigQuery 資料表。 不過,您必須具備必要的 IAM 權限,才能查詢 BigQuery 資料表。前往工具列,確認是否顯示標示為「在 BigQuery 上執行」的按鈕。
如果工具列顯示「執行查詢」,請按一下「設定」圖示 settings,然後選取「BigQuery」。
如果「在 BigQuery 中執行」按鈕已停用,表示沒有連結的資料集。如要解決這項失敗問題,請建立連結的 BigQuery 資料集。
按一下「在 BigQuery 執行」。
定價
如要瞭解使用 BigQuery 的相關費用,請參閱 BigQuery 定價。