Audit Logging System
Planned Design
The audit log will record, per operation:
- What: DDL (CREATE, ALTER, DROP), DML (INSERT, UPDATE, DELETE), and optionally SELECT and transaction statements (BEGIN, COMMIT, ROLLBACK).
- Who and when: user, session, timestamp.
- Outcome: affected rows, success or failure, error message.
- Integrity: a SHA-256 checksum per event for tamper detection.
It will be queryable with SQL from an append-only __audit_log table and configured
in the [audit] section of config.toml:
[audit]enabled = truelog_ddl = truelog_dml = truelog_select = falselog_transactions = falselog_auth = trueretention_days = 90enable_checksums = truemax_query_length = 10000Recording Changes with Triggers
Until built-in audit logging is available, AFTER INSERT OR UPDATE OR DELETE triggers on
sensitive tables can write each change to an audit table you own. Grant auditors
SELECT on that table and revoke write access from application roles. See
Triggers and
Procedural Language for the syntax.
Related Controls Available Today
- Encryption at rest: Encryption Quick Start
- Encryption in transit: PostgreSQL SSL/TLS Configuration
- Access control: SQL roles,
GRANT/REVOKEand row-level security - Point-in-time reads: Time-Travel Queries show what a row contained at an earlier time