pg_auth_mon
monitor connection attempts per user
Repository
RafiaSabih/pg_auth_mon
https://github.com/RafiaSabih/pg_auth_mon
Source
pg_auth_mon-3.0.tar.gz
pg_auth_mon-3.0.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_auth_mon | 3.0 | SEC | MIT | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 7150 | pg_auth_mon | No | Yes | No | Yes | No | Yes | - |
| Related | passwordcheck_cracklib pgaudit pgauditlogtofile login_hook auth_delay credcheck logerrors set_user |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | MIXED | 3.0 | 1817161514 | pg_auth_mon | - |
| RPM | PGDG | 3.0 | 1817161514 | pg_auth_mon_$v | - |
| DEB | PIGSTY | 3.0 | 1817161514 | postgresql-$v-pg-auth-mon | - |
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 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:
| Parameter | Default | Description |
|---|---|---|
pg_auth_mon.log_period | 0 | Dump 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:
| Column | Description |
|---|---|
uid | User OID (0 for invalid/non-existing usernames) |
successful_auth_count | Total number of successful logins |
last_successful_auth | Timestamp of last successful login |
failed_auth_count | Total number of failed authentications |
last_failed_auth | Timestamp of last failed login |
hba_conflicts_count | Count of HBA file conflicts |
All login attempts with invalid usernames are aggregated into a single row with OID 0.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.