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

未关闭
#1,263 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
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 小时
30 天内合并 PR
38

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cloudnative-pg/plugin-barman-cloud 的其他 Issue

查看 cloudnative-pg/plugin-barman-cloud 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。