Overview
OpenSRE uses PostgreSQL diagnostics to investigate database-related alerts — checking server health, surfacing slow queries, monitoring replication status, and analyzing table statistics. All queries are read-only SELECTs.
Prerequisites
- PostgreSQL 10+ (12+ recommended for full
pg_stat_statements support)
- Network access from the OpenSRE environment to your PostgreSQL instance
- A read-only user with access to system views
Setup
Option 1: Interactive CLI
Provide your host, database, and credentials when prompted.
Option 2: Environment variables
Option 3: Persistent store
Credentials
Creating a read-only user
pg_monitor (PostgreSQL 10+) grants read access to monitoring views including pg_stat_activity, pg_stat_replication, and pg_stat_statements without superuser privileges.
Enabling slow query tracking
Add to postgresql.conf:
Restart PostgreSQL, then:
Quick local test with Docker
Verify:
Use a temporary integration-store path so saved integrations cannot override the demo environment variables:
The file does not need to exist. OpenSRE treats the missing temporary store as empty and resolves PostgreSQL from the exported variables above.
Trigger a real investigation against the slow query — this is the actual supported entrypoint, not an internal import:
Real output from a run against this exact local instance (edited for length):
All 6 registered tools were exercised in this single turn.
Teardown:
Verify
Alias: postgres. Expected output:
Troubleshooting
Security
- Use a dedicated read-only user with
pg_monitor — avoid superuser credentials.
- Enable SSL (
POSTGRESQL_SSL_MODE=require) in production.
- Prefer
scram-sha-256 in pg_hba.conf.
- Store credentials in
.env or your secret manager — not in source control.
- Rotate credentials periodically.