Jerome Rajan

0 %
Jerome Rajan
Data & AI Architect at Google
  • Residence:
    India
  • City:
    Mumbai
GCP Agent Platform
GenAI
SQL
Dataproc, EMR
Hadoop
BigQuery
PySpark, Python
Data Pipeline Design
Tableau, Redshift, Snowflake
IBM DataStage
  • AWS Lambda, S3, EMR, SQS, DynamoDB, Step Functions, Cloud Functions
  • Unix Shell Scripting, Python
  • Oracle, DB2, Redis
  • Alteryx, VBA, Blueprism, UiPath
English
Tamil
Hindi
Malayalam
Marathi
Spanish

GCP Cloud Logging: How to Enable Data Access Audit Logs for Selected GCS Buckets

October 4, 2022

Introduction

Data Access Audit Logs are used to trace and monitor API calls that create, modify, or read user data or metadata on any Google Cloud resource. These logs are disabled by default (except for BigQuery Data Access audit logs) because Data Access audit logging can trigger a massive surge in log volume and rapidly drive up Cloud Logging ingestion and storage costs.

Refer to the official guide on enabling Data Access audit logs. You will notice that the IAM audit configuration workflow lets you select which audit log types to enable (ADMIN_READ, DATA_READ, and DATA_WRITE) and specify exempted principals. For example, if a scheduled Dataproc workload reads continuously from a GCS bucket, you can add its service account under exempted principals.

However, IAM audit log settings apply across all Cloud Storage buckets in the project. What if you want to exempt specific high-churn buckets while still auditing sensitive buckets in the same project? In this post, we walk through how to exclude selected GCS buckets at the Cloud Logging Router layer to keep observability sharp and billing predictable.

A Quick Overview of How Cloud Logging Works

All logging activities in Google Cloud Platform (GCP) flow through the Cloud Logging API, which routes incoming entries through the Logs Router.

Google Cloud Logging architecture showing Logs API, Logs Router, and Sinks
Google Cloud Logging routing architecture

Log entries received by the Logging API pass through the Logs Router, where sinks evaluate inclusion and exclusion filters to determine which logs are ingested and where they are stored (Log Buckets, BigQuery, Cloud Storage, or Pub/Sub). Without proper sink exclusions, high-frequency GCS Data Access logs can quickly become one of the largest line items on a GCP invoice.

Step-by-Step Solution

GCP Logs Router console showing _Default and _Required log sinks
  • You will see two pre-configured sinks: _Required and _Default.
  • _Required routes Admin Activity logs, System Event logs, and Access Transparency logs. It cannot be edited or disabled, and logs routed through _Required incur zero ingestion charges.
  • _Default routes all remaining logs—including Data Access audit logs—into the _Default log bucket. Click the three-dot menu next to _Default and select Edit sink.
Selecting Edit Sink on the _Default sink in Google Cloud Logs Router
Configuring a GCS bucket exclusion filter in Google Cloud Logs Router

For example, the exclusion filter below drops all audit log entries generated by API activity on a bucket named demo-bucket:

resource.type="gcs_bucket"
resource.labels.bucket_name="demo-bucket"

You can also filter at the operation level using protoPayload.methodName. For instance, to exclude only noisy object-listing calls on demo-bucket while retaining read/write audits:

resource.type="gcs_bucket"
resource.labels.bucket_name="demo-bucket"
protoPayload.methodName="storage.objects.list"

If you prefer not to modify the built-in _Default sink directly, you can clone or create a dedicated custom sink with your inclusion/exclusion rules—just remember to disable _Default so logs are not ingested twice.

Things to Remember

  • Excluded log entries still count toward the entries.write API quota because sink filtering happens inside the Logs Router after the Logging API receives the entry.
  • Exclusion filters take precedence over inclusion filters—if a log entry matches both, it is excluded.
  • If no filters are configured on an active sink, all matching logs are routed and billed by default.
  • Excluded log entries incur zero Cloud Logging ingestion or storage charges.

Originally cross-published on Google Cloud Community (Medium).

Posted in TechnologyTags:
Write a comment
Be Original
Would the boy you were be proud of the man you are?