CREATE USER opensre_readonly WITH PASSWORD 'secure-password';GRANT pg_monitor TO opensre_readonly;GRANT CONNECT ON DATABASE application_db TO opensre_readonly;\c application_dbGRANT USAGE ON SCHEMA public TO opensre_readonly;GRANT SELECT ON ALL TABLES IN SCHEMA public TO opensre_readonly;
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:
shared_preload_libraries = 'pg_stat_statements'pg_stat_statements.track = all
Restart PostgreSQL, then:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
The file does not need to exist. OpenSRE treats the missing temporary store as empty and resolves PostgreSQL from the exported variables above.Now ask the agent about the slow query:
opensre
Ask: Does the app_db PostgreSQL instance have any slow queries?Against this exact local instance the agent calls all 6 registered tools — slow
queries, server status, current queries, lock status, table stats, and replication
status — and correctly identifies the intentional SELECT pg_sleep($1) call
(~2016 ms average) as the only slow query, with every other health indicator normal.Teardown: