PostgreSQL Health
Check the reachability, connect time, active sessions and database size of a PostgreSQL server.
The PostgreSQL Health check connects to a PostgreSQL server as an ordinary client and reports whether the connection works, how long connecting takes, how many sessions are currently active, and how large the connected database is. The check runs on the agent device you assign it to and connects from there over TCP to the host you enter. It runs on Windows, Linux and macOS (each in x64 and Arm64), every 5 minutes by default. The database server itself does not need to be an agent device; any agent device that can reach it over the network is enough.
Prerequisites
- A login role and a
hostline inpg_hba.confthat admits this role from the agent device's address. Even with the host127.0.0.1the connection arrives over TCP, solocallines do not apply. - For a meaningful active session count, the role needs
pg_monitor(orpg_read_all_stats). Without it, the role sees only its own session's state, and the check permanently reports one active session.
To create the monitoring role and the pg_hba.conf entry, see Set up the database monitoring account.
Steps
- Go to Devices and open the device.
- Click the Checks tab → Add Check → PostgreSQL Health.
Settings
The two connect-time fields sit under Connect-time thresholds in the check form.
Results
Thresholds also trigger on equality. If Warning connect time (ms) is greater than Error connect time (ms), the check swaps the two values before evaluation. The active session count and database size are displayed only and never raise an alert. Connection setup and queries have a fixed 10-second timeout.
Metrics collected
- Connected (yes/no)
- Connect time in milliseconds
- Active sessions: backends in
pg_stat_activitywithstate = 'active', that is, only sessions currently running a statement - Size of the connected database in MB
Notes
- The check opens a new connection on every run and closes it afterwards.
- The host is part of the check configuration. If you assign the check to many devices through a config package, each of them connects to the same server. Assign it to a single device instead, ideally the database server itself.
Was this helpful?
More in Databases & applications
Set up the database monitoring accountDATEVDFSR BacklogDHCP Scope UtilizationStill need help? Ask the team