prometheus-community / postgres_exporter

A PostgreSQL metric exporter for Prometheus
Apache License 2.0
2.79k stars 737 forks source link

Missing pg_stat_statements Metrics #1019

Open wildhi opened 6 months ago

wildhi commented 6 months ago

We had installed the helm chart to collect metrics from postgres. We can Collect very nice metrics, but we can´t find Metrics with 'pg_stat_statements'. We had activate the Extenstion and also in Config Files 'shared_preload_libraries', and i can select Data with the Username from Collector with 'SELECT * FROM pg_stat_statements;'. But only metrics from 'settings' is found, for example 'pg_settings_pg_stat_statements'

psql (PostgreSQL) 12.17

what is my mistake ?

wildhi commented 6 months ago

I Found the Line https://github.com/prometheus-community/postgres_exporter/blob/master/collector/pg_stat_statements.go#L95 this query can´t run on PSQL Version 12.17 because Column Names are different.

Also this line https://github.com/prometheus-community/postgres_exporter/blob/master/collector/pg_stat_statements_test.go#L35

I´m right there ?

isaiasanchez commented 2 months ago

there are two queries for pg_stat_statements, the one you are refering has the condition to run in PG greater that 13:

    if instance.version.GE(semver.MustParse("13.0.0")) {
        query = pgStatStatementsNewQuery
    }

If you read the exporter documentation you need to enable some collectors to be able to see these metrics.