为什么在 Bigquery 中创建事件 table 时 GA4 会加载 3 次?

Why does GA4 load 3 times when creating the event table in Bigquery?

我想知道事件 table 创建作业何时使用 Cloud Logging 完成。

protoPayload.serviceData.jobCompletedEvent.job.jobConfiguration.load.destinationTable.projectId="PROJECT_ID"
protoPayload.serviceData.jobCompletedEvent.job.jobConfiguration.load.destinationTable.datasetId="DATASET_ID"

protoPayload.serviceData.jobCompletedEvent.job.jobConfiguration.load.destinationTable.tableId="TABLE_ID"
protoPayload.serviceData.jobCompletedEvent.job.jobConfiguration.load.writeDisposition="WRITE_TRUNCATE"
protoPayload.methodName="jobservice.jobcompleted"

但我已经检查过在 Cloud Logging 创建事件 table 时 GA4 加载了 3 次。

我的问题是

  1. 为什么在 Bigquery 中创建事件 table 时 GA4 加载 3 次?
  2. 哪个云日志查询会告诉我最终事件 table 何时创建?

提前致谢。看到这个愚蠢的问题的每个人都有美好的一天:)

在 BigQuery 审核日志中使用 User-defined log-based metrics and The AuditData messages,您可以创建一个警报策略,让您知道何时创建了 BigQuery table。

The audit log message system relies on structured logs, and the BigQuery service provides three distinct kinds of messages:

  • AuditData: The old version of logs, which reports API invocations.
  • BigQueryAuditMetadata: The new version of logs, which reports resource interactions such as which tables were read from and written to by a given query job and which tables expired due to having an
    expiration time configured.
  • AuditLog: The logs that BigQuery Reservations and BigQuery Connections use when reporting requests.

使用 BigQueryAuditMetadata,特别是 BigQueryAuditMetadata.TableCreation 事件,您可以使用 JSON格式。

{
  "table": {
    object (BigQueryAuditMetadata.Table)
  },
  "reason": enum (BigQueryAuditMetadata.TableCreation.Reason),
  "jobName": string
}

To create a distribution metric by using the Google Cloud CLI, specify the full metric configuration using the --config-from-file flag. The configuration format is JSON or YAML. For a full description of the LogMetric configuration, see projects.metrics.

有关以下内容的更多详细信息:

在 BigQuery

上创建的新 GA4 导出 table 的日志记录查询

此查询将仅匹配最初的 table 创建条目,因此您每天会收到一个日志事件。

protoPayload.metadata."@type"="type.googleapis.com/google.cloud.audit.BigQueryAuditMetadata"
protoPayload.metadata.tableCreation.reason="JOB"
protoPayload.authorizationInfo.permission:"bigquery.tables.create"
NOT protoPayload.resourceName:"_intraday" -- ignore intraday table creation

多个 GA4 导出连接到单个 BigQuery 项目

通过将 DATASET_NAME 替换为 BigQuery 数据集中的相关 ID 来隔离特定的 table。

protoPayload.metadata."@type"="type.googleapis.com/google.cloud.audit.BigQueryAuditMetadata"
protoPayload.metadata.tableCreation.reason="JOB"
protoPayload.authorizationInfo.permission:"bigquery.tables.create"
NOT protoPayload.resourceName:"_intraday" -- ignore intraday table creation
protoPayload.resourceName:"DATASET_NAME/tables/events_" -- OPTIONAL for BigQuery projects connected to more than one GA4 export