Skip to content

Commit ec0d993

Browse files
fix: WAL health panel false positive on idle databases
The WAL health stat panel (ID 612) shows "Unsynced" (red) on idle databases where no WAL activity is occurring, even though the archiver is functioning correctly. PostgreSQL's archive_timeout only forces WAL segment switches when there are records in the current segment. On idle databases (common in staging/dev), no new WAL segments are produced, causing seconds_since_last_archival to grow indefinitely and the panel to turn red. Fix: multiply the archival age by whether there are actually WAL files pending archival (ready > 0). When no WALs are pending, the result is 0 (Healthy) since the archiver has nothing to do. Fixes #55 Signed-off-by: Christoph Ebeling <c.ebeling@nexode.de>
1 parent 8f1461d commit ec0d993

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

charts/cluster/grafana-dashboard.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,7 +1973,7 @@
19731973
"type": "prometheus",
19741974
"uid": "${DS_PROMETHEUS}"
19751975
},
1976-
"description": "WAL is considered Healthy when the last WAL is 0min to 6min old, Delayed when it is less than 15min and Unsynced for >15min.",
1976+
"description": "WAL is considered Healthy when the last WAL is 0min to 6min old, Delayed when it is less than 15min and Unsynced for >15min. Idle databases with no pending WAL files are shown as Healthy.",
19771977
"fieldConfig": {
19781978
"defaults": {
19791979
"color": {
@@ -2133,7 +2133,7 @@
21332133
"uid": "${DS_PROMETHEUS}"
21342134
},
21352135
"editorMode": "code",
2136-
"expr": "max((1 - cnpg_pg_replication_in_recovery{namespace=~\"$namespace\", pod=~\"$instances\"}) * (time() - timestamp(cnpg_pg_stat_archiver_seconds_since_last_archival{namespace=~\"$namespace\", pod=~\"$instances\"}) +\ncnpg_pg_stat_archiver_seconds_since_last_archival{namespace=~\"$namespace\", pod=~\"$instances\"}))",
2136+
"expr": "max((1 - cnpg_pg_replication_in_recovery{namespace=~\"$namespace\", pod=~\"$instances\"}) * (time() - timestamp(cnpg_pg_stat_archiver_seconds_since_last_archival{namespace=~\"$namespace\", pod=~\"$instances\"}) +\ncnpg_pg_stat_archiver_seconds_since_last_archival{namespace=~\"$namespace\", pod=~\"$instances\"})\n* on(pod, namespace) group_left()\n(cnpg_collector_pg_wal_archive_status{namespace=~\"$namespace\", pod=~\"$instances\", value=\"ready\"} > bool 0))",
21372137
"hide": false,
21382138
"instant": false,
21392139
"legendFormat": "WAL",

0 commit comments

Comments
 (0)