postgres_exporter icon indicating copy to clipboard operation
postgres_exporter copied to clipboard

Missing pg_stat_statements Metrics

Open wildhi opened this issue 2 years ago • 3 comments

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'

  • postgres_exporter version: v0.15.0

  • PostgreSQL version:

psql (PostgreSQL) 12.17

what is my mistake ?

wildhi avatar Apr 11 '24 13:04 wildhi

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 ?

wildhi avatar Apr 12 '24 11:04 wildhi

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.

isaiasanchez avatar Aug 20 '24 10:08 isaiasanchez