Introduction to auditing data compliance

Auditing BigQuery resources lets you evaluate security, maintain data governance, and comply with regulatory policies. Auditing answers the question: Who did what, where, and when?

Auditing and monitoring serve distinct purposes in BigQuery:

  • Auditing evaluates principal activity and resource state for security and compliance, such as tracking dataset and table access, Identity and Access Management (IAM) role changes, and policy tag modifications.
  • Monitoring tracks the operational health, query and job execution performance, slot and reservation utilization, and cost of your workloads. For more information, see Introduction to BigQuery monitoring. Unlike many Cloud de Confiance by S3NS services that write operational application and job execution logs to Cloud Logging, BigQuery writes operational job telemetry to information schema views and uses Logging primarily to emit Cloud Audit Logs (cloudaudit.googleapis.com).

In addition to audit logging, BigQuery integrates with other Cloud de Confiance services to support end-to-end data governance:

Types of auditing in BigQuery

You can perform three main types of auditing in BigQuery:

  • Audit access modifications: track who modified access permissions, which resources (datasets and tables) were affected, and which principals gained or lost access. This includes dataset and table IAM role grants, role revocations, and access control list (ACL) changes.
  • Audit policy tags and column-level security: track when policy tags and dynamic data masking rules are attached, updated, or removed, and verify which principals accessed masked or restricted columns. For more information, see Audit policy tags.
  • Audit data access and table usage: track who read or queried your tables, views, columns, and datasets, and when that access occurred. This activity is recorded in Data Access audit logs.

Audit logs versus information schema views

BigQuery projects contain audit logs for the resources that are directly within the project. Other Cloud de Confiance resources, such as folders, organizations, and billing accounts, contain their own audit logs.

Audit logs are the authoritative source of truth for user identity, authentication, and API method calls. Use audit logs as your primary source for security investigations and compliance audits.

In contrast, information schema views provide operational telemetry about jobs, datasets, tables, and reservations. Information schema views answer questions about query execution dynamics, runtime performance, and resource utilization.

Audit logs contain log entries for API calls, but they don't describe the internal execution dynamics or performance impact of those calls. For example, you can find slot usage, execution stages, and bytes billed in information schema views, but not in audit logs. Furthermore, failed queries don't emit TableDataRead or TableDataChange audit events, and jobCompletedEvent only records completed jobs. To analyze query performance, slot utilization, and operational health, see Introduction to BigQuery monitoring.

Audit log types

BigQuery emits the following types of Cloud Audit Logs:

  • Admin Activity logs: record operations that modify the configuration or metadata of BigQuery resources, such as creating, updating, or deleting datasets, tables, and slot commitments.
  • Data Access logs: record operations that read or write user-provided data, such as running queries, exporting data, and reading table contents.
  • System Event logs: record administrative actions performed by Google systems, rather than direct user actions.
  • Policy Denied logs: record security violations or requests that are blocked by security policies, such as VPC Service Controls perimeter violations.

All of these logs are enabled by default for BigQuery except for some BigQuery services.

Audit log format

Cloud de Confiance services write audit logs in a structured JSON format based on the LogEntry structure. This structure contains the name of the log, the resource that generated the log entry, the timestamp (UTC), and basic request metadata.

The details of the logged event are contained in a subfield called the payload field. For audit logs, the payload field is named protoPayload. The value of this field is an AuditLog structure, indicated by @type set to type.googleapis.com/google.cloud.audit.AuditLog.

For operations on datasets, tables, and jobs, BigQuery writes audit logs in two different formats, although both share the AuditLog base type:

  • Older format (AuditData): details about the operation are written to the protoPayload.serviceData field using the AuditData structure, and resource.type is set to bigquery_resource.
  • Newer format (BigQueryAuditMetadata): details about the operation are written to the protoPayload.metadata field using the BigQueryAuditMetadata structure, and resource.type is set to either bigquery_project (for jobs) or bigquery_dataset (for storage).

Google recommends consuming logs in the newer format. For more information, see Audit logs migration guide.

The following example shows an abbreviated log entry for a failed operation:

{
  "protoPayload": {
    "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
    "status": {
      "code": 5,
      "message": "Not found: Dataset myproject:mydataset was not found in location US"
    },
    "authenticationInfo": { ... },
    "requestMetadata":  { ... },
    "serviceName": "bigquery.googleapis.com",
    "methodName": "google.cloud.bigquery.v2.JobService.InsertJob",
    "metadata": { ... }
  },
  "resource": {
    "type": "bigquery_project",
    "labels": { ... }
  },
  "severity": "ERROR",
  "logName": "projects/myproject/logs/cloudaudit.googleapis.com%2Fdata_access"
}

For operations on BigQuery reservations, the protoPayload field uses the AuditLog structure, and the protoPayload.request and protoPayload.response fields contain additional details. You can find the field definitions in the BigQuery Reservation API. For more information, see Monitor BigQuery reservations.

Limitations

Log entries have a size limit of 100,000 bytes. If a log entry exceeds this limit, Logging truncates the payload. For more information, see Truncated log entry.

Visibility and access control

BigQuery audit logs can include sensitive information, such as SQL query text, schema definitions, and resource identifiers for tables and datasets. To manage access to this information, see the Cloud Logging access control documentation.

Telemetry map

The following table maps BigQuery features and resources to their operational monitoring telemetry, audited API services and resources, and audit log reference documentation. You can use it to find the telemetry that you need to troubleshoot issues, optimize performance, control costs, audit usage, and maintain compliance.

In the following table, an asterisk (*) in an INFORMATION_SCHEMA view name indicates scope-specific view variants, such as _BY_PROJECT, _BY_USER, _BY_FOLDER, and _BY_ORGANIZATION.

Feature or resource Operational monitoring Cloud Audit Logs
Queries and jobs

Information schema views:

  • JOBS*: real-time and historical job execution, slot milliseconds, bytes billed, execution stages, and all submitted jobs regardless of completion status
  • JOBS_TIMELINE*: per-timeslice job state and slot usage

Console:

Metrics: Cloud Monitoring metrics, such as query/count, query/execution_times, and job/num_in_flight.

API service: bigquery.googleapis.com.

Audited resources: jobs in JobService (monitored resource: bigquery_project).

Audit logs: Data Access logs using BigQueryAuditMetadata (JobInsertion and JobChange events), recording who submitted or canceled a job, job status, statement type, and referenced tables or views. See BigQuery audit logs overview.

Tables and views

Information schema views:

Metrics: Monitoring metrics, such as storage/stored_bytes and storage/table_count.

API services: bigquery.googleapis.com and bigquerystorage.googleapis.com. Data Access logs for BigQuery Storage API use bigquery.googleapis.com, while Policy Denied logs use bigquerystorage.googleapis.com.

Audited resources: tables, views, and materialized views in TableService and TableDataService; and storage read sessions and write streams in BigQueryRead and BigQueryWrite (monitored resources: bigquery_dataset and bigquery_table).

Audit logs: Data Access logs using BigQueryAuditMetadata (TableDataRead and TableDataChange events for table reads, modifications, referenced fields, source job, and BigQuery Storage API stream reads and writes), plus Admin Activity, Data Access, and System Event logs for TableCreation, TableChange, and TableDeletion events, including table Identity and Access Management (IAM) policy changes and table expirations. See BigQuery audit logs overview.

Datasets

Information schema views:

API service: bigquery.googleapis.com.

Audited resources: datasets, dataset IAM policies, and dataset ACLs in DatasetService and IAMPolicy (monitored resource: bigquery_dataset).

Audit logs: Admin Activity and Data Access logs using BigQueryAuditMetadata (DatasetCreation, DatasetChange, and DatasetDeletion events), including dataset IAM policy changes in bindingDeltas and ACL updates in accessChanges. See BigQuery audit logs overview.

Slots and reservations

Information schema views:

Console:

Metrics: Monitoring metrics, such as slots/allocated and slots/total_available.

API service: bigqueryreservation.googleapis.com for the BigQuery Reservation API.

Audited resources: reservations, capacity commitments, and reservation assignments in ReservationService (monitored resource: bigquery_project).

Audit logs: Admin Activity and Data Access logs for creating, modifying, deleting, and listing reservations, capacity commitments, and project or folder assignments. See BigQuery Reservation API audit logging.

Column-level security and data masking

Information schema views:

API services: datacatalog.googleapis.com for Data Catalog policy tags, bigquerydatapolicy.googleapis.com for the BigQuery Data Policy API, and bigquery.googleapis.com.

Audited resources: taxonomies and policy tags in PolicyTagManager, data policies in DataPolicyService, and policy-tagged table columns (monitored resources: audited_resource and bigquery_dataset).

Audit logs: Admin Activity and Data Access logs for taxonomy and policy tag management and IAM policy changes (Audit policy tags); data policy management and grantee updates (BigQuery Data Policy audit logging); and TableDataRead.fields logs for reads on protected columns (BigQuery audit logs overview).

Routines, including UDFs and stored procedures

Information schema views:

API service: bigquery.googleapis.com.

Audited resources: user-defined functions (UDFs), table functions, and stored procedures in RoutineService (monitored resources: bigquery_dataset and bigquery_project).

Audit logs: Admin Activity and Data Access logs using BigQueryAuditMetadata (RoutineCreation, RoutineChange, and RoutineDeletion events), plus child job events for stored procedure runs. See BigQuery audit logs overview.

External connections

Information schema views:

  • OBJECT_PRIVILEGES: connection privileges
  • JOBS*: federated queries and remote function jobs that use connections

API service: bigqueryconnection.googleapis.com for the BigQuery Connection API.

Audited resources: connections and connection IAM policies in ConnectionService (monitored resource: audited_resource).

Audit logs: Admin Activity and Data Access logs for connection creation, credential updates, deletion, listing, and IAM policy changes. See BigQuery Connection API audit logging.

BigQuery sharing

Information schema views:

Dashboard: sharing usage metrics dashboard.

API service: analyticshub.googleapis.com.

Audited resources: data exchanges, listings, subscriptions, and exchange or listing IAM policies in AnalyticsHubService (monitored resource: audited_resource).

Audit logs: Admin Activity and Data Access logs for data exchange and listing creation, updates, deletion, IAM policy changes, and subscriber operations. See Sharing audit logging.

BigQuery Data Transfer Service

Metrics and logs:

API service: bigquerydatatransfer.googleapis.com for the BigQuery Data Transfer Service API.

Audited resources: transfer configurations, transfer runs, and data sources in DataTransferService (monitored resource: audited_resource).

Audit logs: Admin Activity and Data Access logs for creating, updating, deleting, listing, and starting transfer configurations and runs. See BigQuery Data Transfer Service audit logging.

BigLake catalogs and tables

Information schema views:

  • TABLES: table metadata
  • JOBS*: external object storage query statistics (metadata_cache_statistics and object_storage_stats)

API services: biglake.googleapis.com and bigquery.googleapis.com.

Audited resources: metastore catalogs, databases, tables, and partitions in MetastoreService and HiveMetastoreService, and Apache Iceberg catalogs, namespaces, and tables in IcebergCatalogService (monitored resources: audited_resource and bigquery_dataset).

Audit logs: Admin Activity and Data Access logs for catalog, database, namespace, table, partition, and catalog IAM policy operations. See BigLake audit logging.

BigQuery Migration Service

Status and reports:

  • Batch SQL translation job status in the Cloud de Confiance console
  • Workflow and subtask status in the BigQuery Migration API
  • Translation summary reports in Cloud Storage

API service: bigquerymigration.googleapis.com for the BigQuery Migration API.

Audited resources: migration workflows, migration subtasks, and SQL translation requests in MigrationService and SqlTranslationService (monitored resource: audited_resource).

Audit logs: Data Access logs for creating, starting, listing, viewing, and deleting migration workflows and subtasks, and translating SQL queries. See BigQuery Migration Service audit logging.

What's next