Already set shared_preload_libraries?
Keep the existing entries and add pg_stat_statements to the comma-separated list.
What you would like to collect from your PostgreSQL?
Collect logs and metrics from your PostgreSQL database using Vector and Prometheus postgres exporter.
The query performance charts in the PostgreSQL dashboard read from the pg_stat_statements extension. Add it to shared_preload_libraries in postgresql.conf and restart PostgreSQL:
Then create the extension:
shared_preload_libraries?Keep the existing entries and add pg_stat_statements to the comma-separated list.
Create a dedicated PostgreSQL user for Vector to scrape metrics. The pg_monitor role lets it read the statistics views, including pg_stat_statements:
Replace your_password_here with password of your choice.
Create /etc/postgres_exporter.conf config file using PostgreSQL user password you've just set:
Install latest postgres exporter:
The exporter's stat_statements collector is off by default. Add --collector.stat_statements to the exporter command in /usr/local/bin/better_stack_postgres_exporter.sh:
The install script regenerates the wrapper without the flag. Re-add --collector.stat_statements after any reinstall.
Start the PostgreSQL exporter:
Select your platform:
Install and configure Vector on Ubuntu or Debian:
Curious about what the script does?
The script will ask for confirmation before making any changes.
You should see your logs in Better Stack → Live tail.
Collect logs from your PostgreSQL database using Vector.
Select your platform:
Install and configure Vector on Ubuntu or Debian:
Curious about what the script does?
The script will ask for confirmation before making any changes.
You should see your logs in Better Stack → Live tail.
Please let us know at hello@betterstack.com.
We're happy to help! 🙏
Find step-by-step instructions in our dedicated Vector guide.
We use cookies to authenticate users, improve the product user experience, and for personalized ads. Learn more.