Skip to content

AI Development Audit Logging Design Guide

Purpose

Design a minimal audit log set that balances three axes: query reproduction, compliance evidence trail, and security incident investigation.

Minimal Log Element Set

FieldDescriptionContains PIIRetention Period
request_idTrace IDNo1y
user_roleCaller roleLow180d
model_nameModel usedNo180d
prompt_hashHash after maskingNo1y
safety_flagsFilter judgment resultNo180d
latency_msProcessing timeNo90d
token_in/outToken countNo90d
decision_reasonRouting/rejection reasonNo180d

Masking Guidelines

1. Replace secrets/credentials with <SECRET_x> via regex + dictionary matching
2. Obscure low-confidence token sequences using Bloom Filter to increase re-identification cost
3. Hashing: prompt -> SHA256(salt+normalized_prompt)

Observability Integration

  • Set prompt_hash/latency/token as OpenTelemetry span attributes
  • Anomaly alerts: error rate + safety_flag ratio deviation detection

Back to: index.md