在 BigQuery 中查詢 Cloud DLP 發現項目

當發現項目轉移至 BigQuery 時,資料會寫入新資料表或現有資料表。如要進一步瞭解動作,請參閱動作概念主題。

查詢範例

您可以使用以下查詢範例分析發現項目,也可以在 Google 數據分析等視覺化工具中使用查詢。這些查詢旨在協助您開始查詢您的發現項目資料。

在下列各項查詢中,請將 [DATASET] 改成您的資料集名稱,將 [TABLE_ID] 改成 BigQuery 資料表 ID,並將 [PROJECT_ID] 改成專案 ID。

選取每種 infoType 的計數

GCP 主控台

SELECT info_type.name,
COUNT(info_type.name) AS count
FROM `[PROJECT_ID].[DATASET].[TABLE_ID]`,
GROUP BY info_type.name
ORDER BY count DESC;

指令列

bq query --use_legacy_sql=false ' SELECT info_type.name, COUNT(info_type.name) AS count FROM [PROJECT_ID].[DATASET].[TABLE_ID], GROUP BY info_type.name ORDER BY count DESC;'

依日期選取每種 infoType 的計數

GCP 主控台

SELECT info_type.name, cast(TIMESTAMP_SECONDS(create_time.seconds) as date) as day,
COUNT(locations.container_name) AS count
FROM `[PROJECT_ID].[DATASET].[TABLE_ID]`,
UNNEST(location.content_locations) AS locations
GROUP BY info_type.name, day
ORDER BY count DESC;

指令列

bq query --use_legacy_sql=false ' SELECT info_type.name, cast(TIMESTAMP_SECONDS(create_time.seconds) as date) as day, COUNT(locations.container_name) AS count FROM [PROJECT_ID].[DATASET].[TABLE_ID], UNNEST(location.content_locations) AS locations GROUP BY info_type.name, day ORDER BY count DESC;'

選取每個容器中每種 infoType 的計數

GCP 主控台

SELECT info_type.name, locations.container_name,
COUNT(locations.container_name) AS count
FROM `[PROJECT_ID].[DATASET].[TABLE_ID]`,
UNNEST(location.content_locations) AS locations
GROUP BY locations.container_name, info_type.name
ORDER BY count DESC;

指令列

bq query --use_legacy_sql=false ' SELECT info_type.name, locations.container_name, COUNT(locations.container_name) AS count FROM [PROJECT_ID].[DATASET].[TABLE_ID], UNNEST(location.content_locations) AS locations GROUP BY locations.container_name,info_type.name ORDER BY count DESC;'

本頁內容對您是否有任何幫助?請提供意見:

傳送您對下列選項的寶貴意見...

這個網頁
Cloud Data Loss Prevention