> ## Content Index
> Fetch the complete content index at: https://shakeride.com/guides/llms.txt
> Use this file to discover other available public pages before exploring further.

# Audit logging of data access
- URL: https://shakeride.com/guides/data-access-audit-logging-costs/
- Published: 2026-11-08T08:00:00.000Z
- Updated: 2026-11-09T20:15:20.000Z
- Description: Data access audit logs record one event per object read or write, so their volume follows traffic. How to scope them to the data that needs an audit trail with CloudTrail data events, Storage diagnostic settings and Data Access audit logs.
- Author: Shakeride
- Tags: Cloud costs, AWS, Azure, Google Cloud, CloudTrail, S3, Blob Storage, Azure Monitor, Cloud Audit Logs, Cloud Storage

**In one sentence:** a data access audit log writes one event per object read or write, so "all buckets, all operations" bills you for every request your own pipelines make; scope it to the data that needs a trail.

## Symptom

The audit logging line of the bill grows with storage request counts, not with admin activity. It started the day someone enabled data access logging account-wide for a compliance review, and it doubles when a batch job or an analytics scan runs.

## How it happens

![An audit setting scoped to all buckets and all operations turns every read by a batch job into an audit event. The events are written to a log bucket that is itself audited, so each log write creates one more event, in a loop.](https://shakeride.com/guides/content/images/2026/11/data-access-audit-logging-costs-audit-loop.svg)

- **Volume follows traffic:** a management event is one per API change; a data event is one per object `GET` or `PUT`. A job reading a million objects writes a million events.
- **The loop:** if the bucket that receives the logs is itself in scope, every log delivery is a write that is logged again.
- Scope by resource, record writes before reads, exempt the high-volume service identity, and keep the log destination out of scope.

## Act

### AWS

Replace "all S3 buckets" with advanced event selectors naming the regulated bucket, and log reads only where an audit requires them. Never select the trail's own log bucket. Check that a second trail does not record the same data events: each copy is billed.

```bash
aws cloudtrail put-event-selectors --trail-name org-trail --advanced-event-selectors '[{"Name":"regulated writes",
  "FieldSelectors":[{"Field":"eventCategory","Equals":["Data"]},{"Field":"resources.type","Equals":["AWS::S3::Object"]},
  {"Field":"readOnly","Equals":["false"]},{"Field":"resources.ARN","StartsWith":["arn:aws:s3:::regulated-data/"]}]}]'

```

### Azure

On the blob service of the account that needs a trail, keep `StorageWrite` and `StorageDelete` and drop `StorageRead` unless an audit asks for reads. Do not enable diagnostic settings on the account that receives the logs, and prefer an archive storage account over Log Analytics for long retention.

```bash
az monitor diagnostic-settings create --name blob-audit --workspace "$LAW_ID" \
  --resource "$(az storage account show -n stregulated --query id -o tsv)/blobServices/default" \
  --logs '[{"category":"StorageWrite","enabled":true},{"category":"StorageDelete","enabled":true}]'

```

### Google Cloud

Data Access audit logs are billed on ingestion, unlike Admin Activity. In the project IAM policy, replace an `allServices` audit config with one for `storage.googleapis.com`, and exempt the pipeline's service account from `DATA_READ`. Apply with `gcloud projects set-iam-policy`.

```yaml
auditConfigs:
- service: storage.googleapis.com
  auditLogConfigs:
  - logType: DATA_WRITE
  - logType: DATA_READ
    exemptedMembers: [serviceAccount:etl@prod-data.iam.gserviceaccount.com]

```

## Keep watch

### AWS

In Cost Explorer, filter on CloudTrail and group by usage type: `DataEventsRecorded` should drop, and `PaidEventsRecorded` reveals duplicate trails. `aws cloudtrail get-event-selectors --trail-name org-trail` proves the scope.

### Azure

Alert on the `Usage` table where `DataType == "StorageBlobLogs"`. Prove the fix: `StorageBlobLogs | where OperationName == "GetBlob"` returns no new rows.

### Google Cloud

Create a log-based metric on `logName:"cloudaudit.googleapis.com%2Fdata_access"` and alert on its rate. Prove the fix: no new entries name the exempted service account.

## Exercise

Restore an audit trail without over-recording: [The activity record went quiet](https://shakeride.com/challenges/the-activity-record-went-quiet?ref=shakeride.com), then [A regulated data set fails its audit](https://shakeride.com/challenges/a-regulated-data-set-fails-its-audit?ref=shakeride.com).

Related: [Log ingestion spikes](https://shakeride.com/guides/log-ingestion-spikes/).