feat(metrics): expose server_name label on barman-cloud backup gauges

オープン
#1,263 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
55/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go, postgresql

調査の方向性

Start with Define() and Collect() in internal/cnpgi/instance/metrics.go, including the populated and zero-value paths; the issue says both CNPG-I and CloudNativePG support variable labels end to end. Check the existing gauge definitions and collection tests, if present. Done means all three barman cloud gauges include server_name populated from configuration.ServerName in both paths; maintainers still need to resolve the object_store and release compatibility questions.

索引モデルが issue の本文から書いたものです。

説明

Human

I came across this when wanting to alert on backups might have been accidentally deleted, and noticed I couldn't easily tell the difference in metrics. Having the server name on these would help :)

Problem

plugin-barman-cloud exposes three gauges on each CNPG instance pod (internal/cnpgi/instance/metrics.go):

  • barman_cloud_cloudnative_pg_io_first_recoverability_point
  • barman_cloud_cloudnative_pg_io_last_available_backup_timestamp
  • barman_cloud_cloudnative_pg_io_last_failed_backup_timestamp

None of them carry a server_name label, even though Collect() already looks up objectStore.Status.ServerRecoveryWindow[configuration.ServerName].

When a platform recreates a Cluster under the same name and namespace with a fresh serverName (for example a timestamped or UUID-suffixed server name, similar to the patterns in #1140 and #1253), the new cluster starts a fresh Barman archive while keeping the old archive intact. In Prometheus, the new cluster writes to the exact same metric series as the previous one. Alerts that track recoverability-window drops (comparing first_recoverability_point over a lookback window) see the restore window drop to zero and fire false positives for a normal recreation.

Proposal

Expose server_name as a variable label on the three barman_cloud_cloudnative_pg_io_* gauges, populated with configuration.ServerName in both the populated and zero-value paths of Collect().

Both cnpg-i (proto/metrics.proto) and CloudNativePG (internal/cnpi/plugin/client/metrics.go, pkg/management/postgres/metrics/collector.go) already support variable_labels end-to-end, so this only requires updating Define() and Collect() in internal/cnpgi/instance/metrics.go.

A couple of design questions for maintainers:

  • Should object_store (from configuration.GetBarmanObjectKey().Name) also be included, or just server_name?
  • Adding a label changes Prometheus series identity on upgrade (which splits range queries once across the upgrade boundary and can affect alerts using without(...) or strict label matching). Is a release note in a minor version fine here, or would you prefer an opt-in flag?
Cardinality and alternatives

Cardinality stays low: one active server_name per cluster at any time, and identical to the cluster name when serverName is not overridden.

Today the workaround is injecting a synthetic label via PodMonitor metricRelabelings from an external controller (or putting it on pod labels with podTargetLabels, which splits every cnpg_* metric on the pod). Exposing server_name directly from the plugin keeps the archive identity with the backup metrics that actually depend on it.


Disclosure: Drafted with an AI assistant (Gemini), which also verified the cnpg-i and CloudNativePG metric collector references against source.

主要言語
Go
スター
214
フォーク
91
平均マージ
2日 11時間
マージ済み PR(30日)
38

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cloudnative-pg/plugin-barman-cloud のほかの issue

cloudnative-pg/plugin-barman-cloud の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。