fix(observability): let Prometheus accept samples after a clock jump #2

Merged
donghyeon.kang merged 1 commits from fix/prometheus-ooo-window into main 2026-11-11 14:18:34 +00:00
Owner

무엇을, 왜

11-11 재부팅 때 RTC의 KST를 UTC로 읽어 시계가 9시간 앞섰다가 NTP가 되돌렸다. 그사이 Prometheus가 TSDB 머리에 18:36~19:36Z 시각의 샘플 한 시간을 썼다. outOfOrderTimeWindow가 chart 기본값 0s라서 그 뒤 수집은 전부 out of bounds로 버려졌다.

  • 11:21Z부터 메트릭이 하나도 쌓이지 않았다. 실제 데이터로 울 수 있는 경보도 없었다.
  • KubeAPIDown(absent() 규칙)은 거짓으로 울렸다.
  • 그대로 두면 시계가 그 시각을 지날 때까지 약 7시간 더 이 상태였다.

이 PR은 prometheus.prometheusSpec.tsdb.outOfOrderTimeWindow를 10h로 둔다. 머리보다 10시간까지 늦은 샘플을 받는다. +9시간 오차를 덮는 값이다. 이유는 README에 적었다.

고른 방법과 버린 대안

  • 버림: Retain PV의 head WAL 지우기. 바로 풀리지만 보존 데이터를 지우고 파드를 멈춰야 한다.
  • 버림: 시계가 따라잡을 때까지 기다리기. 사고 원인을 찾는 몇 시간 동안 관측이 멈춘다.
  • 시계가 튀는 것 자체를 막는 일은 W1의 infrastructure/host 변경(k3s를 시간 동기화 뒤에 시작)이 맡는다. 이 PR은 그래도 튀었을 때 Prometheus가 스스로 회복하게 하는 쪽이다.

위험과 영향

  • 늦은 샘플이 들어올 때만 메모리에 별도 머리를 만들고 vertical compaction을 쓴다. 평소에는 늦은 샘플이 없다.
  • 늦게 보내는 exporter가 있으면 10시간까지 과거 값을 채울 수 있다. 단일 노드 Prometheus라 해가 없다.
  • live에는 이미 같은 값이 들어가 있다(아래 검증). 이 PR을 닫으면 live를 0s로 되돌려야 repo와 맞는다: kubectl -n observability patch prometheus observability-core-kube-pr-prometheus --type merge -p '{"spec":{"tsdb":{"outOfOrderTimeWindow":"0s"}}}'

검증

  • 값 파일을 파싱했다. prometheus.prometheusSpec.tsdb.outOfOrderTimeWindow=10h.
  • live Prometheus CR에는 원래 이 chart 키에서 온 tsdb.outOfOrderTimeWindow: 0s가 있었다. 그래서 이 키가 spec.tsdb로 간다.
  • 같은 값을 live CR에 patch했다. 결과:
    • operator가 out_of_order_time_window: 10h를 썼고, 13:04:37Z에 설정이 다시 읽혔다.
    • 이후 「too old」 경고는 0건이다.
    • 대상 34개가 모두 up이고, KubeAPIDown이 풀렸다.
  • 돌리지 않은 것: 고정 렌더러 scripts/validate/render-observability-core.sh. Helm v3.19.4와 kustomize v5.8.1이 필요한데 노트북·desktop 어디에도 없다.

리뷰어가 볼 곳

  • services/observability/kube-prometheus-stack/values/home.yaml: 두 줄.
  • README 마지막 단락.

관련

  • 2026-11-11 시계 사고. W1 인프라 재발 방지 브랜치 claude/vigorous-booth-e9c7b9(k3s를 시간 동기화 뒤에 시작)
## 무엇을, 왜 11-11 재부팅 때 RTC의 KST를 UTC로 읽어 시계가 9시간 앞섰다가 NTP가 되돌렸다. 그사이 Prometheus가 TSDB 머리에 18:36~19:36Z 시각의 샘플 한 시간을 썼다. `outOfOrderTimeWindow`가 chart 기본값 `0s`라서 그 뒤 수집은 전부 `out of bounds`로 버려졌다. - 11:21Z부터 메트릭이 하나도 쌓이지 않았다. 실제 데이터로 울 수 있는 경보도 없었다. - `KubeAPIDown`(`absent()` 규칙)은 거짓으로 울렸다. - 그대로 두면 시계가 그 시각을 지날 때까지 약 7시간 더 이 상태였다. 이 PR은 `prometheus.prometheusSpec.tsdb.outOfOrderTimeWindow`를 `10h`로 둔다. 머리보다 10시간까지 늦은 샘플을 받는다. +9시간 오차를 덮는 값이다. 이유는 README에 적었다. ## 고른 방법과 버린 대안 - 버림: Retain PV의 head WAL 지우기. 바로 풀리지만 보존 데이터를 지우고 파드를 멈춰야 한다. - 버림: 시계가 따라잡을 때까지 기다리기. 사고 원인을 찾는 몇 시간 동안 관측이 멈춘다. - 시계가 튀는 것 자체를 막는 일은 W1의 `infrastructure/host` 변경(k3s를 시간 동기화 뒤에 시작)이 맡는다. 이 PR은 그래도 튀었을 때 Prometheus가 스스로 회복하게 하는 쪽이다. ## 위험과 영향 - 늦은 샘플이 들어올 때만 메모리에 별도 머리를 만들고 vertical compaction을 쓴다. 평소에는 늦은 샘플이 없다. - 늦게 보내는 exporter가 있으면 10시간까지 과거 값을 채울 수 있다. 단일 노드 Prometheus라 해가 없다. - live에는 이미 같은 값이 들어가 있다(아래 검증). 이 PR을 닫으면 live를 `0s`로 되돌려야 repo와 맞는다: `kubectl -n observability patch prometheus observability-core-kube-pr-prometheus --type merge -p '{"spec":{"tsdb":{"outOfOrderTimeWindow":"0s"}}}'` ## 검증 - 값 파일을 파싱했다. `prometheus.prometheusSpec.tsdb.outOfOrderTimeWindow=10h`. - live Prometheus CR에는 원래 이 chart 키에서 온 `tsdb.outOfOrderTimeWindow: 0s`가 있었다. 그래서 이 키가 `spec.tsdb`로 간다. - 같은 값을 live CR에 patch했다. 결과: - operator가 `out_of_order_time_window: 10h`를 썼고, 13:04:37Z에 설정이 다시 읽혔다. - 이후 「too old」 경고는 0건이다. - 대상 34개가 모두 up이고, `KubeAPIDown`이 풀렸다. - **돌리지 않은 것:** 고정 렌더러 `scripts/validate/render-observability-core.sh`. Helm v3.19.4와 kustomize v5.8.1이 필요한데 노트북·desktop 어디에도 없다. ## 리뷰어가 볼 곳 - `services/observability/kube-prometheus-stack/values/home.yaml`: 두 줄. - README 마지막 단락. ## 관련 - 2026-11-11 시계 사고. W1 인프라 재발 방지 브랜치 `claude/vigorous-booth-e9c7b9`(k3s를 시간 동기화 뒤에 시작)
donghyeon.kang added 1 commit 2026-11-11 13:09:48 +00:00
On 2026-11-11 the desktop booted with the RTC read as UTC while it held
KST, so the clock ran 9 hours ahead until NTP pulled it back. Prometheus
had written one hour of samples stamped 18:36-19:36Z into its TSDB head
during that window. With outOfOrderTimeWindow at the chart default of
0s, every later scrape was older than the head's valid range and was
dropped as "out of bounds". From 11:21Z no metric was stored, no rule
could fire on real data, and KubeAPIDown (an absent() rule) fired
falsely. It would have stayed blind until the wall clock passed the
bogus head time, about 7 hours later.

Set prometheusSpec.tsdb.outOfOrderTimeWindow to 10h. Samples up to 10
hours behind the head are now accepted, which covers the +9h KST-as-UTC
misread. The README records why.

Rejected: deleting the head WAL from the Retain PV. It works at once
but removes persisted data and needs the pod stopped. Rejected: waiting
for the clock to catch up. It leaves monitoring blind for hours during
the period when the cause of the incident is still being found.

Risk: out-of-order samples use an extra in-memory head and vertical
compaction only while they arrive; in normal operation none arrive. A
genuinely late exporter could now backfill up to 10h, which is harmless
on this single-node Prometheus. Preventing the clock jump itself is the
host change in infrastructure/host, not this commit.

Verification: the values file parses and holds
prometheus.prometheusSpec.tsdb.outOfOrderTimeWindow=10h. The live
Prometheus CR already carried tsdb.outOfOrderTimeWindow=0s from this
chart key, so the key maps to spec.tsdb. The same value was patched
onto the live CR: the operator wrote out_of_order_time_window: 10h, the
config reloaded at 13:04:37Z, "too old" warnings dropped to 0, all 34
targets report up, and KubeAPIDown resolved. The pinned renderer
(scripts/validate/render-observability-core.sh) was not run: it requires
Helm v3.19.4 and kustomize v5.8.1, which are not installed on the
laptop or the desktop.
donghyeon.kang merged commit 41b46f64ea into main 2026-11-11 14:18:34 +00:00
donghyeon.kang deleted branch fix/prometheus-ooo-window 2026-11-11 14:18:34 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: donghyeon.kang/platform-core#2