postgres_exporter icon indicating copy to clipboard operation
postgres_exporter copied to clipboard

`pg_stat_*` metrics are reported for all databases on the server, regardless of how they're included / excluded

Open RealOrangeOne opened this issue 1 year ago • 0 comments

What did you do?

When listing data sources to scrape only specific databases on a single postgres server (I'd use autodiscovery, but that looks deprecated), the pg_stat_* metrics include all databases, with no way to exclude them besides modifying any relevant alerts etc.

What did you expect to see?

For pg_stat_* metrics, only metrics for databases we're explicitly scraping are considered

What did you see instead? Under which circumstances?

All databases are scraped. This is clearly visible from the code - there's no filtering being done:

https://github.com/prometheus-community/postgres_exporter/blob/9cfa1321158af0eb9f6b11d06eebd064e57c697b/collector/pg_stat_database.go#L219-L242

Environment

  • System information:

    N/A

  • postgres_exporter version:

    used via Grafana Agent, which seems to be v0.11.1

  • postgres_exporter flags:

    N/A

  • PostgreSQL version:

    15.5.0

RealOrangeOne avatar Jan 04 '24 11:01 RealOrangeOne