監控 BI Engine

BigQuery BI Engine 會使用記憶體快取和更快的執行速度,加速處理 BI 情境的 BigQuery。您可以使用 INFORMATION_SCHEMACloud Monitoring 指標監控加速詳細資料。

Cloud Monitoring

您可以使用 Cloud Monitoring 監控 BigQuery BI Engine,並設定相關快訊。如要瞭解如何建立 BI Engine 指標的資訊主頁,請參閱「建立圖表」。

BigQuery BI Engine 提供下列指標:

資源 指標 詳細資料
BigQuery 專案 預留容量總計 (位元組) 分配給單一 Google Cloud 專案的總容量
BigQuery 專案 預留容量已使用的位元組數 單一專案使用的總容量 Google Cloud
BigQuery 專案 BI Engine 快取位元組數最多的資料表 每個資料表的快取用量。這項指標會顯示各區域報表用量的前 N 個資料表。

BI Engine 的查詢統計資料

本節說明如何找出查詢統計資料,以利監控、診斷及排解 BI Engine 使用問題。

BI Engine 加速模式

啟用 BI Engine 加速功能後,查詢可以下列四種模式執行:

BI_ENGINE_DISABLED
BI Engine 已停用加速功能。 biEngineReasons 會指定更詳細的原因。查詢是使用 BigQuery 執行引擎執行。
PARTIAL_INPUT
查詢輸入的部分內容已使用 BI Engine 加速處理。如「 查詢最佳化和加速」一文所述,查詢計畫通常會細分為多個輸入階段。BI Engine 支援一般類型的子查詢模式,通常用於資訊主頁。如果查詢包含多個輸入階段,但只有少數階段屬於支援的用途,BI Engine 會使用一般 BigQuery 引擎執行不支援的階段,不會加速處理。在這種情況下,BI Engine 會傳回 PARTIAL 加速代碼,並使用 biEngineReasons 填入其他輸入階段未加速的原因。
 FULL_INPUT
 
查詢的所有輸入階段都使用 BI Engine 加速處理。系統會在查詢中重複使用快取資料,並加快讀取資料後立即進行的運算。
 FULL_QUERY
 
整個查詢都使用 BI Engine 加速。

查看 BigQuery API 工作統計資料

您可以透過 BigQuery API 取得 BI Engine 的詳細統計資料。

如要擷取與 BI Engine 加速查詢相關聯的統計資料,請執行下列 bq 指令列工具指令:

bq show --format=prettyjson -j job_id

如果專案已啟用 BI Engine 加速功能,輸出內容會產生新欄位 biEngineStatistics。以下是工作報告範例:

 "statistics": {
    "creationTime": "1602175128902",
    "endTime": "1602175130700",
    "query": {
      "biEngineStatistics": {
        "biEngineMode": "DISABLED",
        "biEngineReasons": [
          {
            "code": "UNSUPPORTED_SQL_TEXT",
            "message": "Detected unsupported join type"
          }
        ]
      },

如要進一步瞭解 BiEngineStatistics 欄位,請參閱工作參考資料

BigQuery 資訊結構定義統計資料

BI Engine 加速統計資料會納入 BigQuery INFORMATION_SCHEMA 檢視畫面,做為 INFORMATION_SCHEMA.JOBS_BY_* 檢視畫面的一部分,位於 bi_engine_statistics 欄中。舉例來說,這項查詢會傳回過去 24 小時內所有目前專案工作的 bi_engine_statistics

SELECT
  creation_time,
  job_id,
  bi_engine_statistics
FROM
  `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE
  creation_time >
     TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY)
  AND job_type = "QUERY"

請使用以下格式,在 INFORMATION_SCHEMA 檢視畫面中,為 project-idregionviews 指定地域性

`PROJECT_ID`.`region-REGION_NAME`.INFORMATION_SCHEMA.VIEW

查看 Looker Studio 資訊架構詳細資料

您可以查看INFORMATION_SCHEMA.JOBS檢視畫面,追蹤 BigQuery 使用的 Looker Studio 報表和資料來源。BigQuery 中的每項 Looker Studio 查詢都會建立含有 report_iddatasource_id 標籤的項目。開啟報表或資料來源頁面時,這些 ID 會顯示在 Looker Studio 網址的結尾。舉例來說,網址為 https://lookerstudio.google.com/navigation/reporting/my-report-id-123 的報表,其報表 ID 為 "my-report-id-123"

下列範例說明如何查看報表和資料來源:

找出每個 Looker Studio BigQuery 工作的報表和資料來源網址

-- Standard labels used by Looker Studio.
DECLARE requestor_key STRING DEFAULT 'requestor';
DECLARE requestor_value STRING DEFAULT 'looker_studio';

CREATE TEMP FUNCTION GetLabel(labels ANY TYPE, label_key STRING)
AS (
  (SELECT l.value FROM UNNEST(labels) l WHERE l.key = label_key)
);

CREATE TEMP FUNCTION GetDatasourceUrl(labels ANY TYPE)
AS (
  CONCAT("https://lookerstudio.google.com/datasources/", GetLabel(labels, 'looker_studio_datasource_id'))
);

CREATE TEMP FUNCTION GetReportUrl(labels ANY TYPE)
AS (
  CONCAT("https://lookerstudio.google.com/reporting/", GetLabel(labels, 'looker_studio_report_id'))
);

SELECT
  job_id,
  GetDatasourceUrl(labels) AS datasource_url,
  GetReportUrl(labels) AS report_url,
FROM
  `region-us`.INFORMATION_SCHEMA.JOBS jobs
WHERE
  creation_time > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)
  AND GetLabel(labels, requestor_key) = requestor_value
LIMIT
  100;

查看使用報表和資料來源產生的工作

-- Specify report and data source id, which can be found at the end of Looker Studio URLs.
DECLARE user_report_id STRING DEFAULT '*report id here*';
DECLARE user_datasource_id STRING DEFAULT '*datasource id here*';

-- Looker Studio labels for BigQuery.
DECLARE requestor_key STRING DEFAULT 'requestor';
DECLARE requestor_value STRING DEFAULT 'looker_studio';
DECLARE datasource_key STRING DEFAULT 'looker_studio_datasource_id';
DECLARE report_key STRING DEFAULT 'looker_studio_report_id';

CREATE TEMP FUNCTION GetLabel(labels ANY TYPE, label_key STRING)
AS (
  (SELECT l.value FROM UNNEST(labels) l WHERE l.key = label_key)
);

SELECT
  creation_time,
  job_id,
FROM
  `region-us`.INFORMATION_SCHEMA.JOBS jobs
WHERE
  creation_time > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)
  AND GetLabel(labels, requestor_key) = requestor_value
  AND GetLabel(labels, datasource_key) = user_datasource_id
  AND GetLabel(labels, report_key) = user_report_id
ORDER BY 1
LIMIT 100;

Cloud Logging

BI Engine 加速是 BigQuery 工作處理程序的一部分。如要檢查特定專案的 BigQuery 工作,請參閱 Cloud Logging 頁面,並使用 protoPayload.serviceName="bigquery.googleapis.com" 做為酬載。

後續步驟