Audit Logs (Pattern)
Problem
Some actions in ION need a tamper-evident, long-retained record distinct from operational telemetry — auth events, security-sensitive data access, config changes, domain state changes on regulated aggregates, automation actions with customer-visible effect, DR operations. Losing or altering these records is a compliance breach; treating them as debug logs undermines the guarantee.
Audit is not logging with a longer retention — it’s a different pipeline with different semantics.
Solution
Emit audit events to a dedicated pipeline with WORM retention and immutable structure.
1. Two-track model
- Observability — logs, metrics, traces (30–90 days, sampled, debug-shaped) → Observability capability.
- Audit — versioned, structured, at-least-once, never sampled, 2+ years retention → this pattern.
2. Audit event shape
Fixed schema (excerpt):
{
"auditVersion": "1.0",
"id": "uuid",
"occurredAt": "ISO-8601",
"actor": { "type", "id", "displayName" },
"action": "<domain>.<verb>@vN",
"resource": { "type", "id", "tenantId" },
"outcome": "success | failure | denied",
"correlationId": "...",
"context": { "sourceIp", "userAgent", "requestId" },
"before": { ... }, // for state changes
"after": { ... }
}
Full schema in Audit Logs capability.
3. Emission
- Use the platform audit SDK — publishes to the
audit.eventsService Bus topic. - Fail-closed on regulated actions — if the emit fails, the originating operation fails.
- At-least-once with retry buffer; combine with idempotency at the audit ingestor.
- Emit synchronously for high-value actions (auth, admin, DR); asynchronously with buffered retry for high-volume domain-state changes.
4. Persistence
- Ingestor writes to immutable blob storage (WORM) + a Log Analytics audit table.
- Hash chain per event references the previous event’s hash — tampering breaks the chain.
- Legal-hold capable.
- Retention 2 years hot + 7 years cold archive.
5. Domain-event overlap
For domain state changes, emit both the domain event (to the event store) and the audit event (to the audit pipeline), with the same correlation ID. The event store is the domain source of truth; audit is the compliance source of truth.
When to use
Mandatory for:
- Auth events (sign-in, token issuance, capability grant, MFA).
- Access to security-sensitive data (PII bulk reads, admin queries).
- RBAC / access-control changes.
- Domain state changes on compliance-relevant aggregates.
- Automation actions with customer-visible effect.
- DR operations (PITR restore, region failover, key rotation).
- Data export / bulk extraction.
- Config changes to security-critical infrastructure.
Not for: general debug telemetry, every HTTP request.
Consequences
Positive
- Compliance-grade tamper-evident record.
- Independent from event store (survives event-store DR).
- Actionable in security investigations.
- Standardised schema and pipeline across ION.
Negative
- WORM storage cost (justified by compliance).
- Fail-closed adds a hard dependency on the audit pipeline.
- Emission overhead on hot code paths.
Failure modes
- Audit-as-logging — flooding audit with debug reduces signal.
- Free-text
action— unqueryable, breaks alerts. - PII in
before/after— audit becomes a data-breach surface. - Fail-open on regulated actions — invisible policy violations.
- Service-local audit store — fragments the compliance source of truth.
References
references/Design Pattern- Audit Logs.md- ADRs: 0006, 0012.
- Capability: Audit Logs (the full pipeline + retention model).
- Related patterns: Auth / AuthZ, Idempotent Write.
Applied in
- Every ION-emitting service via the platform audit SDK
- Watchtower — incident ownership + escalation changes
- Cogs — playbook runs + automation actions
- Pigeon — notification-sent + card-action-taken
- Veritas + Alya BFFs — auth + data-access events
- Platform on-call — DR operations + emergency toggles