pgaudit
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pgaudit | 18.0 | SEC | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 7100 | pgaudit | No | Yes | Yes | Yes | No | Yes | - |
| Related | pgauditlogtofile pg_auditor pg_roast pgmemento table_log pg_drop_events pgelog logerrors pg_stat_log pg_auth_mon data_historization table_version |
|---|
pg15=pgaudit17, pg14=pgaudit16
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 18.0 | 1817161514 | pgaudit | - |
| RPM | PGDG | 18.0 | 1817161514 | pgaudit_$v | - |
| DEB | PGDG | 18.0 | 1817161514 | postgresql-$v-pgaudit | - |
Install
You can install pgaudit directly. First, make sure the PGDG repository is added and enabled:
Install the extension using pig or apt/yum/dnf:
Preload:
Create Extension:
Usage
pgAudit provides detailed session and/or object audit logging via the standard PostgreSQL logging facility, producing audit trails required for government, financial, or ISO certifications.
Configuration Parameters
| Parameter | Default | Description |
|---|---|---|
pgaudit.log | none | Statement classes to log: READ, WRITE, FUNCTION, ROLE, DDL, MISC, MISC_SET, ALL |
pgaudit.log_catalog | on | Log statements when all relations are in pg_catalog |
pgaudit.log_client | off | Show audit log messages to client |
pgaudit.log_level | log | Log level for audit entries |
pgaudit.log_parameter | off | Include statement parameters in log |
pgaudit.log_parameter_max_size | 0 | Max parameter size in bytes (0=unlimited) |
pgaudit.log_relation | off | Separate log entry per relation in SELECT/DML |
pgaudit.log_rows | off | Include row count in log |
pgaudit.log_statement | on | Include statement text in log |
pgaudit.log_statement_once | off | Log statement text only with first entry |
pgaudit.role | (none) | Master role for object audit logging |
Session Audit Logging
Log all DML and DDL with per-relation detail:
Log everything except miscellaneous commands:
Example output:
Object Audit Logging
Grant permissions to an audit role to control which relations are logged:
Now any SELECT or DELETE on the account table will be audit logged.
Log Format
Entries are CSV with fields: AUDIT_TYPE, STATEMENT_ID, SUBSTATEMENT_ID, CLASS, COMMAND, OBJECT_TYPE, OBJECT_NAME, STATEMENT, PARAMETER.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)