postgres_exporter icon indicating copy to clipboard operation
postgres_exporter copied to clipboard

metricPrefix / PG_EXPORTER_METRIC_PREFIX - Not applied for pg_stat_bgwriter etc

Open vishal-h opened this issue 2 years ago • 1 comments

What did you do? The env var PG_EXPORTER_METRIC_PREFIX is set to postgres

What did you expect to see? Then a metric like pg_stat_bgwriter_maxwritten_clean_total should be emitted as postgres_stat_bgwriter_maxwritten_clean_total

What did you see instead? Under which circumstances? The metric prefix is not overwritten. And the metric still is pg_stat_bgwriter_maxwritten_clean_total

Environment

  • System information:

Linux 5.10.0-7-cloud-amd64 x86_64

  • postgres_exporter version:

    0.10.1

  • postgres_exporter flags:

PG_EXPORTER_METRIC_PREFIX=postgres
  • PostgreSQL version:

    13

vishal-h avatar Apr 08 '22 11:04 vishal-h

Not sure why namespace is altered based on metricPrefix https://github.com/prometheus-community/postgres_exporter/blob/d0a3aa991ad0425e461d57c083db2190d4a736b7/cmd/postgres_exporter/postgres_exporter.go#L302

Doing this messes up the builtinMetricMaps. Like pg_stat_database becomes postgres_stat_database and leads to

queryNamespaceMappings error

 pq: relation \"postgres_stat_database\" does not exist"

vishal-h avatar Apr 13 '22 11:04 vishal-h