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).
Related governance capabilities
In addition to audit logging, BigQuery integrates with other Cloud de Confiance services to support end-to-end data governance:
- Data lineage: track upstream and downstream dependencies and inspect how data moves and transforms across tables, views, and pipelines. Data lineage is a feature of Knowledge Catalog that appears within BigQuery. For more information, see Knowledge Catalog overview and Use Knowledge Catalog in BigQuery.
- Sensitive Data Protection: discover, classify, and inspect whether tables or columns contain sensitive data or personally identifiable information (PII). For more information, see Using Sensitive Data Protection to scan BigQuery data.
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.
- For more information, see Configure Data Access audit logs.
- For pricing information, see Google Cloud Observability pricing.
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 theprotoPayload.serviceDatafield using theAuditDatastructure, andresource.typeis set tobigquery_resource. - Newer format (
BigQueryAuditMetadata): details about the operation are written to theprotoPayload.metadatafield using theBigQueryAuditMetadatastructure, andresource.typeis set to eitherbigquery_project(for jobs) orbigquery_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:
Console:
Metrics: Cloud Monitoring
metrics, such as |
API service:
Audited resources: jobs in Audit logs: Data Access logs using |
| Tables and views |
Information schema views:
Metrics: Monitoring
metrics, such as |
API services:
Audited resources: tables, views, and materialized
views in Audit logs: Data Access logs using
|
| Datasets |
Information schema views:
|
API service:
Audited resources: datasets, dataset
IAM policies, and dataset ACLs in
Audit logs: Admin Activity and Data Access logs
using |
| Slots and reservations |
Information schema views:
Console:
Metrics: Monitoring
metrics, such as |
API service:
Audited resources: reservations, capacity
commitments, and reservation assignments in
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:
Audited resources: taxonomies and policy tags in
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 |
| Routines, including UDFs and stored procedures |
Information schema views:
|
API service:
Audited resources: user-defined functions (UDFs),
table functions, and stored procedures in Audit logs: Admin Activity and Data Access logs
using |
| External connections |
Information schema views:
|
API service:
Audited resources: connections and connection
IAM policies in 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:
Audited resources: data exchanges, listings,
subscriptions, and exchange or listing IAM policies in
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:
Audited resources: transfer configurations, transfer
runs, and data sources in 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: |
API services:
Audited resources: metastore catalogs, databases,
tables, and partitions in 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:
|
API service:
Audited resources: migration workflows, migration
subtasks, and SQL translation requests in
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
- To learn how to audit activities related to policy tags, see Audit policy tags.
- To explore audited API methods, resources, and payload definitions, see the BigQuery audit logs reference.
- To track dependencies and data movement across tables and views, see Knowledge Catalog overview.
- To monitor query performance and resource utilization, see Introduction to BigQuery monitoring.