Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any chances to get a primary/standby label into the metrics? #53

Open
mfuhrmann opened this issue Nov 17, 2021 · 0 comments
Open

Any chances to get a primary/standby label into the metrics? #53

mfuhrmann opened this issue Nov 17, 2021 · 0 comments

Comments

@mfuhrmann
Copy link

I am running the SQL exporter on a PostgreSQL cluster and by default, my collected metrics get several labels added.
Also, a hostname label which makes it easy to work with the values of the primary PostgreSQL cluster node. But only, if the primary role is always running on the same node. This works of course, because I know that host XYZ is usually the primary host.

But if you have a failover or maintenance, the primary role could be on another host. So I would have to change all my queries in Alertmanager or Grafana to point to another hostname. This makes of course no sense.
For these cases, it would be awesome to have a label in the metrics that reflect if this metric comes from a primary or a standby/potential node.

For example the query:

postgres=# select pg_is_in_recovery();
pg_is_in_recovery
-------------------
t
(1 row)

would identify if this host is a primary or not. It returns True if recovery is still in progress(so the server is running in standby mode or slave).

Is there a way to get this label into a query definition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant