Audit Logs Implementation
How to add a new audit event type
- Draft the action name (
<domain>.<verb>.<outcome>@v1). - Extend the audit schema with any new
resourceorcontextfields (versioned viaauditVersion). - Update the service’s audit SDK usage to emit the new event type at the correct point in the code path.
- Add integration tests confirming the event lands on the audit topic with all required fields.
- Coordinate with security if it should feed a new alert.
- Merge and deploy via Runway.
How to emit an audit event (service-side)
- Import the platform audit SDK.
- Build the event from the request context, action constants, opaque actor and resource references, outcome, and ambient correlation ID. Include only approved bounded metadata; never copy authorization headers, tokens, cookies, credentials, customer content, or request and response payloads.
- Call
audit.emit(event)— SDK handles topic publication and retry. - For regulated actions, wrap the emission with the fail-closed helper — the operation fails if audit emission fails.
- Never
catchan audit emission failure silently.
How to query the audit history
- Access the platform audit portal / LA workspace (audit role required — read is itself audited).
- Filter by actor, resource, action, or correlation ID.
- For time-range investigation, use the
occurredAtindex. - Export results only through the compliance-approved export workflow.
Sample KQL (audit table):
AuditEvents_CL
| where occurredAt_t between (start .. end)
| where actor_id_s == "<entra-object-id>"
| where action_s startswith "customer."
| project occurredAt_t, action_s, resource_id_s, outcome_s, correlationId_g
| order by occurredAt_t asc
How to respond to a compliance / legal audit request
- Confirm the requesting party has legal authorisation.
- Engage compliance + legal to scope the request.
- Use the audit portal to query the required window, actor reference, and resource reference. Do not broaden the query to collect unrelated customer content.
- Export only the approved fields through the compliance workflow, which emits its own audit event.
- Deliver via the approved secure channel; retain a copy of the request + delivery record.
How to investigate a suspected security incident
- Pivot from the incident indicator (IP, actor, resource ID).
- Query the audit table for all events for that actor in a wide window.
- Correlate to observability by correlation ID — same window, same ID.
- Verify the audit hash chain on the affected window is intact (integrity job status).
- Document findings in the incident record; keep query history for retrospective.
How to add a security alert on an audit signal
- Identify the audit signal (e.g. ≥ 5 auth failures for one actor within 5 min).
- Draft the LA query against the audit table.
- Define the alert rule in IaC — severity, action group (security on-call), runbook URL.
- Test with a synthetic failure sequence in Alpha.
- Roll to Beta / Prod via Runway.
How to verify the hash chain
- Run the periodic integrity job on-demand for a specified window.
- If a break is detected, engage security immediately — this is a P1.
- Preserve the affected blob container’s read-only snapshot.
- Identify the last-known-good hash boundary and log the tampering event (as its own audit event).
How to onboard a new service into the audit pipeline
- Add the platform audit SDK dependency.
- Grant the service’s UAMI Send on the audit Service Bus topic via IaC.
- Identify auditable actions per Guidelines.
- Instrument the service; verify events land in the audit table.
- Register the service’s action names in the platform catalogue.
- Coordinate any derived security alerts with the security team.
How to handle an audit-emission outage
- If the audit topic is unreachable, fail-closed operations should refuse to proceed and return a documented error.
- Buffer non-regulated events via the SDK’s retry queue.
- Engage platform on-call to restore audit topic availability.
- Once restored, verify the retry queue drained; investigate any dropped events.
- Post-incident: reconcile audit vs. event-store records for the outage window.
How to extend retention for a customer contract
- Confirm the extended retention clause in the contract.
- Update the tenant record in the audit pipeline’s retention config via IaC.
- Verify the tenant’s audit records are tagged for extended retention going forward.
- Log the retention change as its own audit event.
How to purge audit data (compliance-approved only)
- Legal/compliance authorises deletion (court order, GDPR right-to-be-forgotten scoped to non-audit-required data).
- Execute the platform’s compliance purge workflow — never direct blob delete.
- The workflow emits an audit event describing the purge scope and justification.
- Verify: the purged records return “purged” markers; the hash chain reflects the purge with justification.
Related
- Architecture, Guidelines
- Capabilities: Observability, Identity, Event-store DR
- ADRs: 0006, 0011, 0012