pgaudit
pgaudit : provides auditing functionality
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 7100 | pgaudit | pgaudit | 18.0 |
SEC | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-r | No | Yes | Yes | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | pgauditlogtofile pg_auditor pg_roast pgmemento table_log pg_drop_events pgelog logerrors pg_stat_log pg_auth_mon data_historization table_version |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG | 18.0 |
18 17 16 15 14 | pgaudit |
- |
| RPM | PGDG | 18.0 |
18 17 16 15 14 | pgaudit_$v |
- |
| DEB | PGDG | 18.0 |
18 17 16 15 14 | postgresql-$v-pgaudit |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| el8.aarch64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| el9.x86_64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| el9.aarch64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| el10.x86_64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| el10.aarch64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| d12.x86_64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| d12.aarch64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| d13.x86_64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| d13.aarch64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| u22.x86_64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| u22.aarch64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| u24.x86_64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| u24.aarch64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| u26.x86_64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
| u26.aarch64 | PGDG 18.0 | PGDG 17.1 | PGDG 16.1 | PGDG 1.7.1 | PGDG 1.6.3 |
Source
github.com/pgaudit/pgaudit
Install
Make sure PGDG repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
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.