postgres_exporter icon indicating copy to clipboard operation
postgres_exporter copied to clipboard

Metric enrichment

Open malcolm061990 opened this issue 5 years ago • 3 comments

Hi. I just started using the latest postgres_exporter in k8s. And it's cool! But I have one issue. I am using single pod in k8s with the env DATA_SOURCE_NAME with two different hosts and DBs:

        env:
        - name: DATA_SOURCE_NAME
          value: "host=host1 port=5432 dbname=db1 user=user1 sslmode=disable,host=host2 port=5432 dbname=db2 user=user2 sslmode=disable"

I want to monitor just availability of DB's using "pg_exporter_last_scrape_error" or "pg_up". But this metrics don't have the DB and hostname in it's data like "pg_locks_count":

# HELP pg_exporter_last_scrape_error Whether the last scrape of metrics from PostgreSQL resulted in an error (1 for error, 0 for success).
# TYPE pg_exporter_last_scrape_error gauge
pg_exporter_last_scrape_error 0

# HELP pg_up Whether the last scrape of metrics from PostgreSQL was able to connect to the server (1 for yes, 0 for no).
# TYPE pg_up gauge
pg_up 1

# HELP pg_locks_count Number of locks
# TYPE pg_locks_count gauge
pg_locks_count{datname="db1",mode="accessexclusivelock",server="host1:5432"} 0

For example, I want to alert if one of DB's can't be accessed (pg_exporter_last_scrape_error returns 1). But how can I add the "broken" DB and host name to the alert if metric doesn't have that info? #452 is about the same issue

malcolm061990 avatar Nov 29 '20 12:11 malcolm061990

pg_up predates multi-host support, and I guess got missed when that was added.

wrouesnel avatar Dec 24 '20 15:12 wrouesnel

pg_up predates multi-host support, and I guess got missed when that was added.

And so what?)

malcolm061990 avatar Dec 25 '20 14:12 malcolm061990

Link to this one #115 I definitely need this feature :-) ! Currently I'm using two postgres_exporter instances (with two services) just because of this problem. The "server" parameter need to be implemented to the pg_up metric.

Thank's for your work, postgres_exporter is a really nice soft !

bazmap avatar Apr 11 '24 21:04 bazmap