Glossary · BigQuery
What is Cloud Audit Logs for BigQuery?
Cloud Audit Logs record who did what in BigQuery: Admin Activity logs for changes to datasets, tables and jobs, Data Access logs for jobs and table reads and writes, and System Event logs for expirations. BigQuery Data Access logs are on by default and cannot be disabled.
What BigQuery writes to Cloud Audit Logs
BigQuery sends audit logs to Cloud Logging under the service name bigquery.googleapis.com, in three streams:
- Admin Activity (
activity): creating, updating and deleting datasets and tables, IAM changes and other configuration changes. Always on. - Data Access (
data_access):JobInsertionandJobChangeevents for jobs, andTableDataReadandTableDataChangeevents for which tables were read or written. For most Google Cloud services these logs are off by default; for BigQuery they are on and cannot be disabled. - System Event (
system_event): actions by Google systems, such as a table deleted because it expired.
Use the newer BigQueryAuditMetadata format, in protoPayload.metadata; the older AuditData format is not populated for new features. Some cases produce no entry: failed jobs log no TableDataRead or TableDataChange, cache hits log no reads, and Storage Write API appends log no TableDataChange.
Why they matter for cost and observability
Audit logs show the movement of data without reading it: which job wrote which table, when, from which sources and by whom. That is enough to build table lineage, detect tables that stopped updating and find tables nobody reads, and it is how log-based tools such as Masthead monitor BigQuery without access to the data. For cost work they answer questions INFORMATION_SCHEMA cannot, such as which datasets are read but never written.
Query them in BigQuery
Create a log sink that routes BigQueryAuditMetadata entries to a dataset; by default it creates date-sharded tables such as cloudaudit_googleapis_com_data_access_20261123. The metadata arrives as a JSON string in protopayload_auditlog.metadataJson. This query counts reads and writes per table over the last week:
SELECT
REGEXP_EXTRACT(protopayload_auditlog.resourceName,
r'^projects/[^/]+/datasets/([^/]+)/tables/') AS dataset,
REGEXP_EXTRACT(protopayload_auditlog.resourceName,
r'^projects/[^/]+/datasets/[^/]+/tables/(.+)$') AS table_name,
COUNTIF(JSON_QUERY(protopayload_auditlog.metadataJson, '$.tableDataRead') IS NOT NULL) AS reads,
COUNTIF(JSON_QUERY(protopayload_auditlog.metadataJson, '$.tableDataChange') IS NOT NULL) AS writes,
MAX(IF(JSON_QUERY(protopayload_auditlog.metadataJson, '$.tableDataChange') IS NOT NULL,
timestamp, NULL)) AS last_write
FROM `ops-project.audit_logs.cloudaudit_googleapis_com_data_access_*`
WHERE _TABLE_SUFFIX >= FORMAT_DATE('%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY))
GROUP BY dataset, table_name
ORDER BY writes DESC;
Tables with writes but no reads are candidates for unused tables: you pay to build and store them for nobody. Filtering on _TABLE_SUFFIX keeps the query from scanning every day of logs.
Cost of the logs themselves
Data Access logs can be large, and Cloud Logging charges for storage beyond the default retention of the _Default bucket. Routing them to BigQuery adds storage and query costs instead, so keep only the BigQueryAuditMetadata entries you need and partition or expire the log tables. Each log entry is capped at 100,000 bytes, so very long SQL text can be truncated.
For job-level cost data, prefer INFORMATION_SCHEMA.JOBS; for who changed or read what, audit logs are the source of record. See BigQuery pricing for storage and query rates.
FAQ
Should I use audit logs or INFORMATION_SCHEMA.JOBS for BigQuery cost analysis?
Use INFORMATION_SCHEMA.JOBS for cost and performance: it has bytes billed, slot time and every submitted job, including failed ones, for 180 days. Use audit logs for who did what: they are the definitive record of access and configuration changes, and they can be kept as long as you route them.
How long are BigQuery audit logs kept?
Admin Activity and System Event logs go to the _Required bucket and are kept 400 days. Data Access logs go to the _Default bucket, kept 30 days by default. Route them to a BigQuery dataset with a log sink to keep them longer and query them with SQL.
Do BigQuery audit logs contain the data that was read?
No. They record identities, methods, SQL text, schemas and the tables a job read or changed, not row values. They can still be sensitive, so restrict access to the log dataset.
