PostgreSQL
The PostgreSQL module covers PostgreSQL servers, self-hosted or Azure Database for PostgreSQL flexible servers, through a read-only monitoring role: connections, replication lag, transaction ID wraparound, table bloat, the slowest statements and the security posture.
Native collection from PostgreSQL is not available in this release. The module's checks are added to a PostgreSQL server resource, but they stay Unknown until a release brings the PostgreSQL transport. For Azure flexible servers, the Azure Monitor source already brings CPU, memory and storage.
What it monitors
| Area | Checks | Why it matters |
|---|---|---|
| Capacity | Connections used against max_connections; estimated dead tuples of the largest tables | Running out of connections refuses new sessions; bloat wastes disk and slows scans |
| Availability | Replication lag per standby; transaction ID age per database | Lag is data a failover would lose; wraparound forces PostgreSQL to stop writes |
| Performance | The slowest statements from pg_stat_statements | Shows which queries cost the most time |
| Security | Superusers that can log in, SSL, pg_hba rules that trust or accept any address | Settings the CIS PostgreSQL Benchmark flags |
What works today for Azure flexible servers:
| Check | Through | Measures |
|---|---|---|
azure.pgflex_health | Azure Monitor source | CPU, memory and storage of the flexible server, with fired Azure Monitor alerts |
Every check, with its rule, cause and action, is in the reference for PostgreSQL checks.
Before you begin
Prepare the role now, so collection starts as soon as it is available:
-
A monitoring role with
pg_monitor, the built-in role that reads statistics and settings without access to data:CREATE ROLE usr_monitoring WITH LOGIN PASSWORD '<long random password>';GRANT pg_monitor TO usr_monitoring; -
The
pg_stat_statementsextension in the database the role connects to, for the slowest statements check. -
Access to
pg_hba_file_rulesfor thepg_hbapart of the security posture check. By default only superusers can read that view. -
Network. The Excubius server reaches the server on TCP 5432.
-
Store the role as a SQL login credential. See Store a credential for the collector.
For flexible servers in Azure, set up the Azure Monitor source with PostgreSQL flexible servers among its resource types.
Add a resource
Flexible servers come from the Azure Monitor source by themselves. For a self-hosted server, open Resources › Add resource, choose PostgreSQL server (Flexible or self-hosted), enter its host and port, and choose the credential. See Add a resource.