feat(monitoring): cut over Grafana to Thanos Querier and shrink Prometheus retention#5083
feat(monitoring): cut over Grafana to Thanos Querier and shrink Prometheus retention#5083outductor wants to merge 1 commit into
Conversation
…theus retention 3 件をまとめて反映: 1. Grafana の Prometheus datasource を thanos-query.monitoring:9090 に向け替え。 ローカル直近 (sidecar) と Garage 上の長期 (store gateway) が透過的に見える。 2. Prometheus retention 180d / 270GB → 75d / 240GB に縮退。 Garage の Thanos object store のカバー開始は 2026-03-01 (sidecar 導入時) で、 ローカル retention の終端が Garage 開始より新しいと Querier から欠損するため、 (today - 2026-03-01) + 数日マージンで設定。時間が経って Garage カバーが伸びれば 段階的にさらに縮められる。 3. thanos Application に ignoreDifferences を追加。 jsonnet で明示していない volumeClaimTemplates[].spec.volumeMode を k8s が server-side で 'Filesystem' default 補完するため、永続的な OutOfSync ノイズが 出ていた。上流 thanos-config 側で明示するのが本筋だが、まずノイズを止める。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the Prometheus configuration to route Grafana queries through Thanos Querier and adjusts local retention settings to align with the Thanos object store's coverage start date. Additionally, it configures ArgoCD to ignore default volumeMode differences in Thanos StatefulSets to prevent persistent OutOfSync states. Feedback suggests increasing the retentionSize to 260GB to ensure the 75-day time-based retention is not preempted by size-based purging, which could otherwise create data gaps between local storage and the long-term store.
| retention: 75d | ||
| retentionSize: "240GB" |
There was a problem hiding this comment.
PRの説明にある「ピーク約 3.4GB/日」という数値に基づくと、retentionSize: "240GB" は約 70.5 日分(240 / 3.4)の保持に相当します。これは設定されている retention: 75d よりも短いため、時間ベースの保持期間に達する前にサイズベースの削除が優先される可能性が高いです。
Garage のカバー開始(2026-03-01)から本日(2026-05-08)までの経過日数が約 68 日であることを考えると、マージンが 2.5 日程度しかなく、将来的にインジェスト量が増加した場合に 68 日を下回り、Thanos Querier 経由で見た際にデータの欠損(ギャップ)が生じるリスクがあります。
PVC サイズが 300Gi(約 322GB)であることを踏まえ、WAL 等のオーバーヘッドを考慮しても retentionSize を 260GB 程度に引き上げ、時間ベースの 75d が優先的に機能するように調整することを検討してください。
retention: 75d
retentionSize: "260GB"
Summary
#5037 で Thanos Querier / Store / Compactor を立ち上げてから 3 日経過し、smoke test 通過を確認したので 本来のゴール 3 件をまとめて反映 する PR。
prometheus-kube-prometheus-prometheus:9090) → Thanos Querier 経由 (thanos-query.monitoring:9090)。ダッシュボード側の編集は不要 (UIDPBFA97CFB590B2093のまま、URL だけ変える)180d / 270GB→75d / 240GB。当初の目的だった PVC 容量逼迫の根本解消volumeClaimTemplates[].spec.volumeModeのサーバ側 default 補完による永続 OutOfSync ノイズを抑制(2) の retention 値の根拠
Garage 側の Thanos object store のカバー開始は 2026-03-01 (Thanos sidecar が prometheus-operator.yaml に追加された日)。それ以前のデータは Garage には存在しない (sidecar 自体が無かったため)。したがって:
today - 2026-03-01 ≒ 68 日将来 (1ヶ月後など) に再評価して、Garage カバー期間が伸びていれば retention をさらに縮められる (例えば 2026-06 時点で 45d 程度まで)。
(1) の効果と影響
--query.replica-label=prometheus_replicaで dedup する仕組みが既に動く(3) の背景
/api/v1/storesで StoreAPI 接続は確認済みだが、ArgoCD が StatefulSet をOutOfSyncと表示し続けていた。原因はvolumeClaimTemplates[].spec.volumeModeが jsonnet 側で未指定 → server-side でFilesystemが default 補完される → ArgoCD diff が永続発生。実害無いが運用ノイズなので抑制。(本来は
thanos-config側で明示するのが筋だが、retention 縮退と切り離す方が PR が clean なので ArgoCD ignoreDifferences 側で対処。thanos-config側に明示する追従 PR は別途出すかどうか相談)切替え手順 / Test plan
https://grafana.onp-k8s.admin.seichi.click/d/minecraft-servers/minecraft-servers) で過去 1 時間のメトリクスが従来通り表示されるkubectl -n monitoring get pvc prometheus-prometheus-kube-prometheus-prometheus-db-prometheus-prometheus-kube-prometheus-prometheus-0の使用量が compaction 経由で時間とともに減少していく (今 300GB 使用、最終的に 240GB 弱に収束する見込み)thanosApplication が Synced/Healthy になる (現在 OutOfSync/Healthy)🤖 Generated with Claude Code