如何处理“prometheus”和“prometheus_replica”标签?

Nee*_*hna 5 prometheus prometheus-operator

在普罗米修斯的分层联合设置中,我看到了“prometheus”和“prometheus_replica”标签。系统正在监控 Kubernetes 的 StatefulSet 部署。

在查询或提醒时,我看到由于这些标签而包含重复数据,即我看到带有这些标签和没有这些标签的指标。有效地导致错误的计数和警报。

我看到在 prometheus 上的查询中使用了“prometheus”和“prometheus_replica”标签,这些标签从联合端点提取指标。

我在每个 kube 集群上使用 ServiceMonitor 和 Prometheus 运算符。所有指标都被联合到一个不同的 Prometheus 中,在那里可以看到这个问题。

是否有关于如何生成这些标签的文档?这些指标是重复的还是被忽略的?

Sha*_*bak 5

我也遇到了这个问题,只需根据此处的文档为任何获得此评论的人添加影响此问题的配置选项https://github.com/prometheus-operator/prometheus-operator/blob/ca400fdc3edd0af0df896a338eca270e115b74d7/Documentation /api.md#prometheusspec。链接到这里的代码https://github.com/prometheus-operator/prometheus-operator/blob/ca400fdc3edd0af0df896a338eca270e115b74d7/pkg/prometheus/promcfg.go#L95-L132

replicaExternalLabelName:Prometheus 外部标签的名称,用于表示副本名称。默认为 prometheus_replica 的值。当 value 设置为空字符串 ("") 时,不会添加外部标签。
prometheusExternalLabelName:Prometheus 外部标签的名称,用于表示 Prometheus 实例名称。默认为 prometheus 的值。当 value 设置为空字符串 ("") 时,不会添加外部标签。

因此,如果您想删除这些重复项,只需在集群中的 Prometheus 自定义资源中将这些选项设置为空字符串即可。


Nee*_*hna 1

我终于找到了来自 prometheus 操作员的这些标签。添加它是为了满足任何文档中未写明的要求。我发现它在 0.17 版本中不起作用。它适用于 0.23 版本的 Operator。