pg_stat_statements, creating a dedicated monitoring user, and running the QueryComment collector.
QueryComment reads aggregate query, engine, and infrastructure telemetry. The collector does not proxy application traffic and does not write to your application tables.
Prepare PostgreSQL
1
Enable pg_stat_statements
QueryComment uses If Restart PostgreSQL, then create the extension in the database you want to monitor:
pg_stat_statements to read aggregate statement statistics keyed by queryid.Check whether it is already loaded:pg_stat_statements is not listed, add it to postgresql.conf or your managed database parameter group. Also disable utility statement tracking:2
Create the monitoring user
Connect as a privileged PostgreSQL user and run:
pg_monitor gives the QueryComment collector read access to PostgreSQL monitoring views. pg_read_all_stats lets the receiver read queryid and statement statistics for statements run by other roles.3
Verify access
Confirm the monitoring user can read statement statistics:If this query fails, confirm that
pg_stat_statements is installed in the database used by the collector connection string.Configure the QueryComment collector
Use the QueryComment collector with the bundled PostgreSQL receiver. The collector is available as theghcr.io/querycomment/collector:0.1.2 Docker image or as a release package for your operating system.
Set these environment variables before starting the collector:
Example
.env file: