prometheus-community / postgres_exporter

A PostgreSQL metric exporter for Prometheus
Apache License 2.0
2.72k stars 725 forks source link

No pg_stat_activity_count metric scraped #514

Closed uqix closed 3 years ago

uqix commented 3 years ago

No pg_stat_activity_count metric scraped with default helm chart values(with correct datasource config) and default postgresql 11.10 config, here is postgres_exporter pod log:

time="2021-04-05T10:33:48Z" level=info msg="Error running query on database \"172.25.241.133:5432\": pg_stat_statements pq: relation \"pg_stat_statements\" does not exist" source="postgres_exporter.go:1503"
time="2021-04-05T10:33:48Z" level=error msg="queryNamespaceMappings returned 1 errors" source="postgres_exporter.go:1621"
headyj commented 1 year ago

@uqix I have the exact same issue, could you please tell me how you solved it?

uqix commented 1 year ago

@headyj we need to enable pg_stat_statements on pg side:

https://www.postgresql.org/docs/11/pgstatstatements.html

  1. configure: load lib pg_stat_statements
  2. restart postgresql service
  3. CREATE EXTENSION pg_stat_statements; for any database you want to monitor

e.g. postgresql.conf

shared_preload_libraries = 'pg_stat_statements'

# default=5000
pg_stat_statements.max = 10000

# default=top
pg_stat_statements.track = all
headyj commented 1 year ago

Thank your for your answer @uqix , unfortunately I already did that but it's still not working :(