How to Configure Spanner Audit Log
You set up a spanner audit log by turning on data read and write logs in your cloud project IAM rules. This setup sends every database action to your central log sink for review. Most teams start by turning on admin activity logs at the project level. Then they add data read and write logs for sensitive databases. Still, broad IAM roles often let engineers run any query once they log in. Native logs record these wide queries only after the data leaves the database. How the native spanner audit
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up a spanner audit log by turning on data read and write logs in your cloud project IAM rules. This setup sends every database action to your central log sink for review. Most teams start by turning on admin activity logs at the project level. Then they add data read and write logs for sensitive databases. Still, broad IAM roles often let engineers run any query once they log in. Native logs record these wide queries only after the data leaves the database.
How the native spanner audit log works
Cloud Spanner uses the cloud provider logging system to track database events. It splits these events into admin activity, data access, and system events. Admin logs track when someone creates, changes, or deletes an instance or database. These admin logs stay on by default and do not add extra cost. Data access logs track who reads or writes rows inside your tables. These logs stay off by default because they can create huge log volumes.
To turn on data logs, an admin updates the project or instance IAM policy. You pick the Spanner service and check the boxes for admin reads, data reads, and data writes. You can also add exempted principals to skip logging for trusted automated apps. Once turned on, every query creates a log entry with the caller identity and database path. Teams then route these log entries to storage buckets or analytics tables for long-term retention.
What native logging solves and what it misses
Native audit logging gives security teams a clear record of past database activity. It shows which cloud identity ran a command and when the request happened. This record helps teams pass audits and investigate incidents after a breach occurs. It also tracks schema changes and role updates across all regional and multi-region instances. For automated apps with tight roles, this cloud log trail works very well.
Still, native logs only tell you what happened after a query finishes running. IAM roles decide who can log in, not what individual statements do in flight. If an engineer has a read role, they can query an entire table of emails or card numbers. The native log records the read event, but it does not block a bad query. It also cannot mask sensitive fields like phone numbers or national IDs in the query results. Also, high-volume data read logs can drive up cloud storage bills very fast.
Audit Log Integrity + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Managing log volume and sensitive data
When teams turn on all data read logs, every single select statement writes a new log record. Busy production apps can create millions of log entries every hour. To control costs, admins often exempt service accounts from data read logging. This cuts log noise while still tracking human users who log in to run ad-hoc queries. Yet even with human logging on, raw PII still flows back to the user client.
Security teams need a way to inspect queries before the database runs them. They also need a way to rewrite matched fields like emails and card numbers in results. Relying only on cloud IAM and post-event logs leaves production data exposed during live sessions. Adding statement-level checks and field masking closes this gap while keeping your audit trail clean.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Does turning on the spanner audit log increase cloud costs?
Admin activity logs are free, but data read and write logs can create high log ingestion and storage fees on busy databases.
Can I turn on data logs for just one Spanner instance?
You can set audit rules at the team, folder, or project level. You can exempt specific service accounts to reduce log noise.
Do native audit logs mask sensitive fields in query results?
No, native logs only record that a request happened and do not rewrite emails, phone numbers, or card numbers returned to the user.
Related guides
In this post