The Difference Between Postgres Logging and PGAudit
Postgres's built-in logging is designed for operational monitoring and troubleshooting, while PGAudit produces structured audit logs for compliance regimes like HIPAA, SOX and PCI DSS. PGAudit supports session auditing by statement class (READ, WRITE, ROLE, DDL, etc.) and object auditing through an audit role, and emits AUDIT:-prefixed entries with session and statement counters. A side-by-side healthcare example shows standard logging writing a CREATE USER password in plaintext where PGAudit redacts it, and PGAudit labeling reads, writes, role switches and permission failures explicitly. The recommendation is to run both, ship audit logs to a SIEM, and set retention policies such as HIPAA's six years.
Related posts
- How We Export Postgres Logs to Third-Party Services
Neon mediumAdept
Neon exports customer Postgres logs by having Postgres write to rsyslogd alongside stderr, with rsyslogd pushing RFC 5424 syslog over TCP to an OpenTelemetry Collector that enriches and forwards them to Datadog or any OTLP-compatible platform. Scraping pods by label wasn't supported by the OTel Collector, and unstructured logs from multiple NeonVM processes made filtering unreliable, so they switched from pull to push. Roadblocks included rsyslogd requiring a restart rather than a config reload, and a k8sattributes bug fixed by a transform step that copies net.peer.ip into k8s.pod.ip for pod matching. The same rsyslogd instance also ships pg_audit logs to secure storage for HIPAA customers.
- Postgres Auditing in 150 lines of SQL
Supabase mediumAdeptA generic table-auditing system can be built inside PostgreSQL with about 150 lines of SQL: a single append-only audit.record_version table stores each row's old and new contents as JSONB, populated by a per-row trigger enabled via audit.enable_tracking(). Stable record IDs are derived by hashing the table OID plus primary-key values into a UUID v5, so a row's history can be queried by an indexed UUID. A BRIN index on the timestamp and a B-tree on table_oid keep time-range and per-table queries fast. Overhead is typically negligible under ~1000 writes/sec; higher-throughput tables should consider pgAudit, and the code is packaged as the supa_audit extension.
- How Seemplicity scaled real-time security analytics with Postgres CDC and ClickHouse
ClickHouse easyNovice
Seemplicity, a security remediation platform aggregating findings from 150+ tools, outgrew a Postgres-only design as heavy upserts, table bloat and multi-table joins across ~16 per-tenant tables slowed customer dashboards. It kept Postgres as the transactional layer and streamed changes into ClickHouse via PeerDB (now ClickPipes), choosing it over a Debezium–Kafka pipeline to avoid extra failure points. A multi-region staging-then-per-tenant-schema layout and denormalized AggregatingMergeTree tables with materialized views removed query-time joins. Dashboards that once took minutes now return in seconds or milliseconds, and storage is roughly 10 TB, an estimated 5–6x smaller than Postgres, while handling tens of billions of updates per month.
- How to Keep Staging in Sync with Production in Postgres
Neon mediumAdept
Postgres staging environments drift from production, and the traditional fixes each fall short. pg_dump/pg_restore gives a clean copy but takes staging offline and runs for hours on large databases. Logical replication and AWS DMS keep rows in sync but not schema or configuration, and they add load to production. All three copy PII as-is. Database branching with copy-on-write storage, as in Neon, makes staging an instantly resettable branch of production, and an intermediate anonymized branch masks sensitive columns before staging and dev branches are derived from it.
- Security Disclosure Recommendation: Rotate PostgreSQL Database Credentials
Railway mediumAdeptAfter Railway's October 21, 2026 security disclosure, PostgreSQL users on the Railway template should regenerate the database password from the Database View, which changes it inside PostgreSQL and updates POSTGRES_PASSWORD and the variables that reference it in one step. Dependent services must then be redeployed because containers only read variables at startup, and pasted connection strings should be replaced with reference variables. Afterwards, verify with pg_stat_activity, terminate unknown sessions, disable public TCP proxy access if unneeded, and check audit logs, failed-auth logs, unexpected roles and modified data for misuse. Editing password variables or running ALTER USER by hand leaves the variable and the database out of sync, so avoid it.