監控 BI Engine

BigQuery BI Engine 會使用記憶體快取和更快速的執行作業,加快 BigQuery 的 BI 情境。您可以使用 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 檢視表,做為 bi_engine_statistics 資料欄中的 INFORMATION_SCHEMA.JOBS_BY_* 檢視表的一部分。舉例來說,這項查詢會傳回過去 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 的報表有 "my-report-id-123" 報表 ID。

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

找出每個 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"

後續步驟