Windows
1. Create a monitoring role
CREATE USER watchlog_monitor WITH PASSWORD 'your_password';
GRANT pg_monitor TO watchlog_monitor;
GRANT CONNECT ON DATABASE myapp TO watchlog_monitor;
pg_monitor exists from PostgreSQL 10. On 9.6 use pg_read_all_stats instead.
Allow the role to connect in pg_hba.conf, usually at:
C:\Program Files\PostgreSQL\16\data\pg_hba.conf
host all watchlog_monitor 127.0.0.1/32 scram-sha-256
Then reload:
Restart-Service -Name "postgresql-x64-16"
2. Install pg_stat_statements (optional but recommended)
This unlocks the Queries and Slow Queries tabs. Watchlog will never install it for you.
Edit postgresql.conf:
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.track = top
shared_preload_libraries needs a full restart, not a reload:
Restart-Service -Name "postgresql-x64-16"
Then, once per database:
\c myapp
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
3. Configure the agent
- Open the config file:
C:\Program Files\watchlog-agent\integration.json - Locate the PostgreSQL section:
{ "service": "postgresql", "monitor": false, "host": "localhost", "port": "5432", "username": "", "password": "", "database": [] }
3. Change `"monitor"` to `true` and update the fields:
```diff
- "monitor": false
+ "monitor": true
Populate the
databasearray, e.g.:"database": ["myapp", "analytics"]Cluster-wide metrics need no list. This array decides which databases get per-table and per-index detail, because those views only describe the database you are connected to.
Restart the service:
Restart-Service -Name "WatchlogAgent"
Verify
$env:PGPASSWORD='your_password'
psql -h 127.0.0.1 -U watchlog_monitor -d postgres -c "SELECT current_setting('server_version');"
psql -h 127.0.0.1 -U watchlog_monitor -d postgres -c "SELECT count(*) FROM pg_stat_database;"
psql -h 127.0.0.1 -U watchlog_monitor -d myapp -c "SELECT left(query,40) FROM pg_stat_statements LIMIT 1;"
If the last one returns <insufficient privilege>, the role is missing pg_read_all_stats — grant pg_monitor.
TLS
{
"service": "postgresql",
"monitor": true,
"host": "pg.internal",
"port": "5432",
"username": "watchlog_monitor",
"password": "your_password",
"database": ["myapp"],
"ssl": true
}
The agent uses the Windows certificate store. A private CA must be installed into Local Computer → Trusted Root Certification Authorities, not the current user's store, because the agent runs as a service.
Slow queries
Nothing to enable beyond the extension. Watchlog reads pg_stat_statements rather than a log file, so there is no threshold to configure server-side and no log write cost.
slowQuery.thresholdMs only decides what the dashboard labels slow. Query text is already normalized by PostgreSQL — see the integration overview for how utility statements are handled, since those are stored verbatim and need scrubbing.
