Audit Logging for PostgreSQL
Audit Logging for PostgreSQL
with PostgreSQL
David Steele
Postgres Open
September 17, 2015
About the Speaker
2
2ndQuadrant’s Contribution
3
Agenda
4
What is Audit Logging
5
Why Audit Log
6
How to Audit Log
• Triggers
• Won’t do SELECTs
• Event triggers can be used for most DDL (improved in
9.5) but not ROLE commands
• Functions
• All inserts, selects, updates, etc. are done through
functions
• log_statement = all
• Catches all client statements
• Is very hard to parse and can miss nuances that might not
be obvious.
• No way to filter - it’s the proverbial firehose
7
How to Audit Log (pgAudit)
8
pgAudit Design (and Caveats)
9
Example (log_statement = all)
• User statement:
DO $$
BEGIN
EXECUTE 'CREATE TABLE import' || 'ant_table (id INT)';
END $$;
10
Example (pgAudit)
• User statement:
DO $$
BEGIN
EXECUTE 'CREATE TABLE import' || 'ant_table (id INT)';
END $$;
11
Life at one of the big four audit firms.
12
Demo Time!
13
Thank You! Questions?
email: [email protected]
14