refactor(postgres): keep the backup alerts with the backup

The observability core renderer rejects any alert or record whose
name contains "backup" (no_unscoped_monitors_rules): backup
monitoring is outside the observability core by design. f19ce54 put
PlatformPostgresBackupMissing and PlatformPostgresWALArchiveBacklog in
core-rules.yaml, so the pinned renderer failed with "out-of-scope
monitor or rule is present".

Move both alerts unchanged into
services/platform-postgres-backup/prometheus-rule.yaml in
platform-data, which Prometheus reads because the namespace has
observability.hyeonworks.com/enabled=true and the rule has
observability.hyeonworks.com/instance=home. They now point their
runbook_url at the backup README and are applied with the
ScheduledBackup. Renaming them to dodge the filter was rejected: it
would keep backup rules inside a scope that excludes them on purpose.

Verification: test-platform-disk-alerts.sh loads both rule files and
passes; promtool checks 13 rules. render-observability-core.sh and
test-render-observability-core.sh pass, and kubectl apply
--dry-run=server accepts the backup kustomization with the rule.
scan-platform-sensitive-source.sh stops at its observability-core
renderer with RC=23 here and on an origin/main snapshot alike, so it
says nothing about this change.

Fixes: f19ce54740 ("feat(postgres): back up platform-postgres to AIStor every day")
This commit is contained in:
DongHyeonka
2026-11-12 07:28:31 +09:00
parent 2b1310972c
commit d7c845ca5d
5 changed files with 64 additions and 37 deletions
@@ -113,36 +113,6 @@ spec:
summary: 루트 파일시스템 inode 사용률이 90%를 초과함
description: 노드 루트 파일시스템 inode 사용률이 심각 임계치인 90%를 15분간 초과했습니다.
runbook_url: https://git.learn.hyeonworks.com/donghyeon.kang/project-infra/src/branch/main/docs/runbooks/2026-07-31-observability-access-cutover.md
- name: platform.backup
rules:
# cnpg_collector_last_available_backup_timestamp is 0 until the first
# base backup, so a cluster without backups fires as well.
- alert: PlatformPostgresBackupMissing
expr: >-
time() - max by (job, namespace) (
cnpg_collector_last_available_backup_timestamp{job="platform-postgres",namespace="platform-data"}
) > 26 * 3600
for: 30m
labels:
severity: critical
annotations:
summary: platform-postgres에 26시간 안에 끝난 백업이 없음
description: platform-postgres의 마지막 성공한 base backup이 26시간보다 오래됐거나 없습니다. 매일 03:00 KST 백업(ScheduledBackup platform-postgres-daily)을 확인하세요.
runbook_url: https://git.learn.hyeonworks.com/donghyeon.kang/project-infra/src/branch/main/docs/runbooks/2026-07-31-observability-access-cutover.md
# A failing archive_command keeps WAL in pg_wal, which then fills the
# PostgreSQL volume.
- alert: PlatformPostgresWALArchiveBacklog
expr: >-
max by (job, namespace) (
cnpg_collector_pg_wal_archive_status{job="platform-postgres",namespace="platform-data",value="ready"}
) > 10
for: 15m
labels:
severity: critical
annotations:
summary: platform-postgres의 WAL이 보관소로 올라가지 않음
description: 보관을 기다리는 WAL 파일이 10개를 넘은 채 15분이 지났습니다. 보관이 막히면 WAL이 PostgreSQL 볼륨에 쌓여 디스크가 찹니다.
runbook_url: https://git.learn.hyeonworks.com/donghyeon.kang/project-infra/src/branch/main/docs/runbooks/2026-07-31-observability-access-cutover.md
- name: platform.monitoring
rules:
# When the TSDB rejects every sample (2026-11-11: the clock went back