LoginSignup
2
0

More than 1 year has passed since last update.

BigQueryでテーブルの作成者を監査ログから調べる方法

Last updated at Posted at 2022-12-06

BigQueryのテーブルはDETAILSタブから多くの情報を確認することができますが、テーブルの作成者に関する情報は載っていません。

スクリーンショット_2022-11-24_20_54_27.png

なので、監査ログからテーブルの作成者を調べる方法について説明します。
まずは、以下の記事を参考に監査ログをBigQueryに保存します。

その後、以下のクエリを実行することで、テーブルの作成を行ったユーザーを調べることができます。

select
  protopayload_auditlog.authenticationInfo.principalEmail as email,
  split(protopayload_auditlog.resourceName, "/")[safe_offset(1)] as project_id,
  split(protopayload_auditlog.resourceName, "/")[safe_offset(3)] as dataset_id,
  split(protopayload_auditlog.resourceName, "/")[safe_offset(5)] as table_id,
  timestamp,
from `<プロジェクトID>.audit_log.cloudaudit_googleapis_com_activity_*`
where
protopayload_auditlog.serviceName = "bigquery.googleapis.com" and
array_length(protopayload_auditlog.authorizationInfo) = 1 and
protopayload_auditlog.authorizationInfo[safe_offset(0)].permission = "bigquery.tables.create" and
regexp_contains(protopayload_auditlog.resourceName, r'projects/.+/datasets/.+/tables/.+')
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0