You inherit a managed environment whose audit-log retention is “thirty days, because the open-source default was thirty days.” Your SOC 2 auditor wants the entire observation window plus a buffer. Your privacy officer wants twelve months of evidence for incident reconstruction. Your GDPR-bound European tenant wants logs deleted as soon as they are no longer needed, not retained indefinitely. Three retention regimes pulling in three different directions, and a single Loki tenant configured for thirty days. The conversation starts polite and ends with the privacy officer asking why this is not already fixed.
It is fixable in a single config, and the answer is two tiers — hot indexed retention plus cold immutable archive — with the boundary set at thirteen months.
What’s happening
Three regimes drive audit-log retention requirements, and they do not contradict each other once you separate “how long must I be able to query this” from “how long must I be able to produce this if subpoenaed.”
SOC 2 does not specify a numeric retention period. The auditor wants evidence that covers the observation window — typically twelve months for an annual Type II — plus a reasonable buffer for sample requests that come in after the window closes. In practice this means logs from at least thirteen months ago must be retrievable. The Type II evidence-collection cron pulls daily snapshots, so the live log store does not have to retain everything indefinitely — but the snapshots must be retained for the audit window, and the live store must cover the lookback the auditor’s sample request implies.
PIPEDA does not specify retention either, but the OPC’s published guidance frames retention in terms of the purpose for which the information was collected. For audit logs, the operational reading is: keep them long enough to investigate confidentiality incidents, but not longer than the legitimate purpose requires. Twelve to twenty-four months for security-incident reconstruction is defensible; ten years of raw access logs is harder to defend if the logs contain personal information (IPs, user IDs, request payloads).
GDPR Article 5(1)(e) — storage limitation — requires personal data to be kept no longer than necessary for the purposes. Audit logs that contain personal data (IPs, user IDs, email addresses in request payloads) fall under this. Recital 49 and Article 32 carve out security purposes — you may keep logs for security incident detection and investigation — but the principle of necessity still applies. Indefinite retention “in case the auditor asks in five years” is not a valid GDPR purpose.
The intersection: thirteen months of hot, indexed retention satisfies SOC 2 lookback for an annual Type II, supports PIPEDA incident reconstruction, and is defensible under GDPR’s necessity principle. Seven years of cold, immutable archive — typically WORM object storage with object-lock — satisfies the long-tail obligations (litigation hold, regulatory inquiries, retrospective fraud investigation) without keeping raw personal data in a hot index where it would be subject to access requests and would expand the GDPR data-protection footprint.
The cold archive is structured: it is the daily evidence bundle the SOC 2 cron produces, not raw log lines. By the time logs hit the cold tier they have been through redaction passes — IP addresses truncated to /24, user identifiers replaced with non-reversible hashes for the personal-information component, but structurally identical for audit purposes. The auditor can reconstruct “how often did the admin role acquire elevated permissions in Q2 2024” from the cold archive; the cold archive does not let you say “this specific IP visited at this specific time.”
The other piece that makes the policy operate cleanly: the log shipper drops fields it does not need. Application logs at debug verbosity routinely capture full request and response bodies, which routinely contain personal information that has no audit value. The shipper’s pipeline rewrites those before the log lands in either tier. The auditor’s interest is “who did what when,” not “what was the JSON payload of every request.”
How to verify
Three checks tell you whether the policy is actually in effect.
# 1. Hot tier: what is the oldest log line in the hot index?
logcli query --since=395d --output=raw \
--limit=1 '{app="audit"}' | head -1
# If this returns empty for any date inside 395 days, hot retention is short.
# 2. Cold tier: what does today's evidence bundle look like in object storage?
aws s3 ls "s3://acme-soc2-evidence/$(date -u +%F)/" --recursive --summarize \
| tail -3
# You want to see today's bundle, with the manifest file, totalling several MB.
# 3. Personal-information rewrite: does a recent log entry redact a request body?
logcli query --limit 5 --output=raw '{app="api"} |= "POST /users"' \
| grep -oE '"email":"[^"]*"'
# You want to see "email":"<redacted>" or "email":"sha256:..." — not raw emails.
If the hot tier returns less than 395 days, your SOC 2 Type II lookback is in jeopardy. If the cold tier is missing or sparse, your long-tail obligations are not covered. If the request bodies still carry raw personal information, your GDPR storage-limitation posture is materially weaker than the policy claims.
The fix
The Loki / Grafana stack is the cheapest way to operate the hot tier; any S3-compatible object store with object-lock and a lifecycle rule operates the cold tier. The configuration below is the Loki side — set retention_period: 395d on the audit-log tenant, push everything older to S3 with a Promtail-side filter that hashes the personal-information fields.
# /etc/loki/config.yml — audit-log tenant settings
compactor:
retention_enabled: true
retention_delete_delay: 24h
limits_config:
retention_period: 395d # 13 months — SOC 2 lookback + buffer
reject_old_samples: true
reject_old_samples_max_age: 168h
# Per-tenant override for tenants whose data-residency contract forbids 13-month
# retention. They get the shorter window, plus a contractual carve-out documented
# in the description of services.
overrides:
eu-tenant-1:
retention_period: 180d
eu-tenant-2:
retention_period: 180d
Promtail’s pipeline drops or hashes the high-risk fields before the line is indexed:
# /etc/promtail/config.yml — pipeline excerpt
pipeline_stages:
- json:
expressions:
ip: client_ip
email: req_body.email
sin: req_body.sin
# Truncate IP to /24
- replace:
expression: '(\d+\.\d+\.\d+)\.\d+'
replace: '$1.0'
# Hash email
- template:
source: email
template: '{{ if .email }}sha256:{{ .email | sha256sum | first 16 }}{{ end }}'
# Drop SIN entirely — never enters either tier
- drop:
expression: '.*"sin":'
The cold archive is the daily SOC 2 evidence cron, with object-lock in compliance mode for seven years:
# One-time bucket configuration
aws s3api create-bucket --bucket acme-audit-cold --region ca-central-1 \
--create-bucket-configuration LocationConstraint=ca-central-1 \
--object-lock-enabled-for-bucket
aws s3api put-object-lock-configuration --bucket acme-audit-cold \
--object-lock-configuration '{
"ObjectLockEnabled": "Enabled",
"Rule": { "DefaultRetention": { "Mode": "COMPLIANCE", "Years": 7 } }
}'
aws s3api put-bucket-lifecycle-configuration --bucket acme-audit-cold \
--lifecycle-configuration file:///etc/lifecycle.json
The lifecycle policy transitions objects to Glacier Deep Archive after 90 days — hot for the recent past, cheap for the long tail — but the object-lock keeps them in place regardless.
The description of services line that lands cleanly with the auditor: “Audit logs are retained for thirteen months in a hot, queryable tier, with personal-information fields hashed or truncated at ingest. A redacted daily evidence bundle is archived for seven years in immutable object storage with object-lock in compliance mode. Hot-tier retention can be shortened to one hundred and eighty days for tenants whose contract requires it; the override is documented and reviewed quarterly.” That sentence covers SOC 2, PIPEDA, and GDPR in one paragraph, and it is concretely verifiable.
If your audit-log posture is “thirty days because it was the default,” operating it under Managed Cloud Ops puts the two-tier retention into the standard runbook set — or scope a logging-stack rebuild if the gap is wider than a config change.