Skip to content

pg_up metric incorrectly remains 1 even when postgres_exporter fails to connect to the database #1120

Open
@mikezsin

Description

@mikezsin

/metrics endpoint continues to report pg_up as 1 even after the exporter loses connectivity to the PostgreSQL database.

Reproduction Steps

Start postgres_exporter normally

curl db-example-slave.example.com:9187/metrics | grep pg_up
pg_up 1

Break the Connection by Removing the ACL:
Edit pg_hba.conf and comment out the ACL entry for the postgres_exporter
Reload the PostgreSQL.

Check the pg_up metric again:
curl db-example-slave.example.com:9187/metrics | grep pg_up

Expected: pg_up should change to 0 indicating a connection failure.
Observed: pg_up remains at 1, falsely indicating that the exporter is still connected.

time=2025-02-06T23:17:10.121+03:00 level=ERROR source=collector.go:175 msg="Error opening connection to database" err="error querying postgresql version: pq: no pg_hba.conf entry for host "192.0.2.100", user "postgres_exporter", database "postgres", SSL off"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions