fix(postgres): compute replication lag without the idle-primary artifact
upstream replication 컬렉터는 수신 LSN != 재생 LSN이면 now()-마지막 트랜잭션 재생 시각을 지연으로 보고한다. replica 재시작 직후에는 수신 LSN이 세그먼트 시작점(재생 LSN보다 작음)에 머물러 유휴 프라이머리에서 지연이 무한히 커진다(실측 116초→281초, 트랜잭션 1건 뒤 0). DbReplicationLag가 pending으로 올라갔다. 수신 LSN <= 재생 LSN이면 0으로 보는 custom query로 교체하고 upstream replication 컬렉터를 끈다. pg_replication_is_replica도 같은 쿼리에서 낸다.
This commit is contained in:
1 parent
4f3188b491
commit
bc8a8fbc97
2 files changed
+23
-3
No files matched your search
@@ -1,9 +1,11 @@
|
||||
// Alloy on db-primary / db-replica (design 4.1 / 4.3): postgres exporter (built-in collectors: pg_replication_lag_seconds,
|
||||
// pg_up, pg_stat_*) + custom pg_is_wal_replay_paused -> Mimir; PostgreSQL logs -> Loki. instance = VM name.
|
||||
prometheus.exporter.postgres "db" {
|
||||
data_source_names = [sys.env("PG_DSN")]
|
||||
data_source_names = [sys.env("PG_DSN")]
|
||||
custom_queries_config_path = "/etc/alloy/queries.yaml"
|
||||
disable_settings_metrics = true
|
||||
disable_settings_metrics = true
|
||||
// defaults minus "replication": pg_replication_* come from queries.yaml (idle-primary artifact, see there)
|
||||
enabled_collectors = ["database", "locks", "replication_slot", "roles", "stat_bgwriter", "stat_database", "stat_progress_vacuum", "stat_user_tables", "statio_user_tables", "wal"]
|
||||
}
|
||||
|
||||
prometheus.scrape "db" {
|
||||
|
||||
Reference in new issue
Block a user