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

Move pg_stat_replication queries to collector package #966

Open
SuperQ opened this issue Nov 23, 2023 · 1 comment
Open

Move pg_stat_replication queries to collector package #966

SuperQ opened this issue Nov 23, 2023 · 1 comment

Comments

@SuperQ
Copy link
Contributor

SuperQ commented Nov 23, 2023

Proposal

There are existing queries for pg_stat_replication in cmd/postgres_exporter/queries.go. These metrics should be migrated to the collector package.

@Efiartes
Copy link

Efiartes commented Nov 23, 2023

This affects replication monitoring in the way that if only pg_up and pg_replication_lag_seconds are monitored in Secondary servers and there's a network outage between Primary and Secondary servers, Secondary servers get lagged without any alarm being triggered.

It seems more reasonable to monitor replication looking at Primary server data.
SELECT COUNT(*) FROM pg_stat_replication WHERE client_addr='SLAVE_IP' AND state = 'streaming';
If it returns 0, we have an unreachable Secondary server.

SELECT COALESCE(EXTRACT(EPOCH FROM replay_lag)::bigint, 0) AS replay_lag FROM pg_stat_replication WHERE client_addr='SLAVE_IP';
If it returns more than X we have a lagged Secondary server.

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

2 participants