pg_auth_mon

monitor connection attempts per user

Overview

PackageVersionCategoryLicenseLanguage
pg_auth_mon3.0SECMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
7150pg_auth_monNoYesNoYesNoYes-
Relatedpasswordcheck_cracklib pgaudit pgauditlogtofile login_hook auth_delay credcheck logerrors set_user

Version

TypeRepoVersionPG VerPackageDeps
EXTMIXED3.01817161514pg_auth_mon-
RPMPGDG3.01817161514pg_auth_mon_$v-
DEBPIGSTY3.01817161514postgresql-$v-pg-auth-mon-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
PGDG 2.0
el8.aarch64
PGDG 2.0
el9.x86_64
PGDG 2.0
PGDG 2.0
el9.aarch64
PGDG 2.0
el10.x86_64
el10.aarch64
d12.x86_64
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
d12.aarch64
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
d13.x86_64
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
d13.aarch64
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
u22.x86_64
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
u22.aarch64
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
u24.x86_64
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
u24.aarch64
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0
PIGSTY 3.0

Build

You can build the DEB packages for pg_auth_mon using pig build:

pig build pkg pg_auth_mon         # build DEB packages

Install

You can install pg_auth_mon directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install pg_auth_mon;          # Install for current active PG version
pig ext install -y pg_auth_mon -v 18  # PG 18
pig ext install -y pg_auth_mon -v 17  # PG 17
pig ext install -y pg_auth_mon -v 16  # PG 16
pig ext install -y pg_auth_mon -v 15  # PG 15
pig ext install -y pg_auth_mon -v 14  # PG 14
dnf install -y pg_auth_mon_18       # PG 18
dnf install -y pg_auth_mon_17       # PG 17
dnf install -y pg_auth_mon_16       # PG 16
dnf install -y pg_auth_mon_15       # PG 15
dnf install -y pg_auth_mon_14       # PG 14
apt install -y postgresql-18-pg-auth-mon   # PG 18
apt install -y postgresql-17-pg-auth-mon   # PG 17
apt install -y postgresql-16-pg-auth-mon   # PG 16
apt install -y postgresql-15-pg-auth-mon   # PG 15
apt install -y postgresql-14-pg-auth-mon   # PG 14

Create Extension:

CREATE EXTENSION pg_auth_mon;

Usage

pg_auth_mon: Monitor authentication attempts

pg_auth_mon stores authentication attempt statistics per user, tracking successful and failed logins with timestamps.

CREATE EXTENSION pg_auth_mon;

Configuration

Add to postgresql.conf:

shared_preload_libraries = 'pg_auth_mon'

Optional GUC:

ParameterDefaultDescription
pg_auth_mon.log_period0Dump stats to Postgres log every N minutes (0=off)

Querying Authentication Stats

SELECT * FROM pg_auth_mon;

The pg_auth_mon view provides per-user information:

ColumnDescription
uidUser OID (0 for invalid/non-existing usernames)
successful_auth_countTotal number of successful logins
last_successful_authTimestamp of last successful login
failed_auth_countTotal number of failed authentications
last_failed_authTimestamp of last failed login
hba_conflicts_countCount of HBA file conflicts

All login attempts with invalid usernames are aggregated into a single row with OID 0.


Last Modified 2026-03-12: add pg extension catalog (95749bf)