Skip to content
InfraChallenge Docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Logging and audit trail

What is logged, where it goes, how long it stays, what is never logged, and the two layers of audit.

Where logs go

Source Format Destination in AWS Retention
Application events (server/app/telemetry.py) JSON, one event per line awslogs driver to /ecs/<name>-server, stream prefix server log_retention_days: dev 30, staging 90, prod 365
Uvicorn access and error lines Plain text; tracebacks reduced to the exception type Same group and stream Same
Collector sidecar Its own log lines /ecs/<name>-server, stream prefix otel-collector Same
EMF metric events JSON, written by the collector /ecs/<name>-metrics; CloudWatch turns them into the Patent/Server metric Same

Both log groups are encrypted with the customer-managed logs key from the observability module (infrastructure/modules/service/ecs.tf). Retention values are starting values, set per environment in envs/*/terraform.tfvars. Prod’s 365 days covers a 12-month SOC 2 Type II period.

Logs do not go through the collector, so a collector failure loses metrics and traces, never logs.

Because each line is JSON, CloudWatch Logs Insights can query fields directly:

fields @timestamp, outcome, `error.type`, trace_id
| filter event = "suggestion.failed"
| stats count() by `error.type`

What is never logged

  • Document content or model output, in any form.
  • Exception messages and tracebacks. Only the exception type is recorded. See the privacy rule.
  • The OpenAI API key, request headers or request bodies. The httpx spans hold method, URL and status only.

Two layers of audit

audit.document.read is logged when GET /api/document/{id} returns a document, and audit.document.saved when POST /api/save/{id} changes a row. Each line has document.id, document.chars (the size of the content), client.address, a timestamp and the trace ID of the request.

Limits, stated plainly:

  • No actor. The application has no authentication, so there is no user to record. Identity in the audit trail comes with authentication.
  • The address is the load balancer’s. Behind the ALB, client.address is the ALB’s private address, because uvicorn trusts X-Forwarded-For only from 127.0.0.1. Recording the real client needs the address that CloudFront adds to X-Forwarded-For, which is not built.
  • Not tamper-evident. The events sit in a CloudWatch log group that the account’s administrators can delete. A copy to a write-once store is not built.

Who changed the infrastructure, who read a secret, who opened the logs: that is CloudTrail, not the application. Not built:

  • A CloudTrail organisation trail into a separate log-archive account, with object lock.
  • AWS Config, GuardDuty and Security Hub.
  • Access logs for the ALB, CloudFront and WAF.

They are listed under Known gaps and come next in Limits and next steps.

Who can read the logs

Anyone with CloudWatch Logs read access in the account. That includes the Terraform plan role, which has ReadOnlyAccess (see Known gaps). The logs carry no document text, so this exposes metadata (document IDs, sizes, addresses, timings) and not content.

Was this page helpful?