pg_auth_mon
monitor connection attempts per user
pg_auth_mon : monitor connection attempts per user
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 7150 | pg_auth_mon | pg_auth_mon | 3.0 |
SEC | MIT | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-r | No | Yes | Yes | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | set_user login_hook pg_session_jwt auth_delay logerrors pg_stat_log pgelog pgaudit pg_permissions |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | MIXED | 3.0 |
18 17 16 15 14 | pg_auth_mon |
- |
| RPM | PGDG | 3.0 |
18 17 16 15 14 | pg_auth_mon_$v |
- |
| DEB | PIGSTY | 3.0 |
18 17 16 15 14 | postgresql-$v-pg-auth-mon |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 3.0 | PGDG 3.0 | PGDG 2.0 | PGDG 2.0 | PGDG 2.0 |
| el8.aarch64 | PGDG 3.0 | PGDG 3.0 | PGDG 2.0 | PGDG 2.0 | PGDG 2.0 |
| el9.x86_64 | PGDG 3.0 | PGDG 3.0 | PGDG 3.0 | PGDG 3.0 | PGDG 3.0 |
| el9.aarch64 | PGDG 3.0 | PGDG 3.0 | PGDG 3.0 | PGDG 3.0 | PGDG 3.0 |
| el10.x86_64 | PGDG 3.0 | PGDG 3.0 | PGDG 3.0 | PGDG 3.0 | PGDG 3.0 |
| el10.aarch64 | PGDG 3.0 | PGDG 3.0 | PGDG 3.0 | PGDG 3.0 | PGDG 3.0 |
| 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 |
| u26.x86_64 | PIGSTY 3.0 | PIGSTY 3.0 | PIGSTY 3.0 | PIGSTY 3.0 | PIGSTY 3.0 |
| u26.aarch64 | PIGSTY 3.0 | PIGSTY 3.0 | PIGSTY 3.0 | PIGSTY 3.0 | PIGSTY 3.0 |
Source
github.com/RafiaSabih/pg_auth_mon
pg_auth_mon-3.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
Usage
pg_auth_mon stores authentication attempt statistics per user, tracking successful and failed logins with timestamps.
Configuration
Add to postgresql.conf:
Optional GUC:
| Parameter | Default | Description |
|---|---|---|
pg_auth_mon.log_period |
0 |
Dump stats to Postgres log every N minutes (0=off) |
Querying Authentication Stats
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.