prometheus - 在普罗米修斯中查找重复标签

标签 prometheus promql

我们有多个服务器,上面有多个客户。有时,我们将客户从一台服务器复制到另一台服务器,然后将 DNS 指向新服务器。 现在的问题是旧服务器仍然报告该客户的一些普罗米修斯指标,这会导致重复的数据集和错误的数据。

为了清理数据,我们需要一种方法来识别那些重复的数据集。

示例数据:

orders(customer="a", server="1") = 200
orders(customer="b", server="1") = 299
orders(customer="c", server="2") = 10
orders(customer="a", server="2") = 10

我们正在寻找一些 PromQL 来为我们提供以下输出:

a: 2
b: 1
c: 1

请注意,我对此处的值不感兴趣 - 只是对唯一数据点的数量感兴趣。

有什么想法吗?

最佳答案

使用 count 并根据要求和的标签(使用 by 关键字)进行分组,在本例中为 customer

count(orders) by (customer)

看看这个 live example

关于prometheus - 在普罗米修斯中查找重复标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69454012/

相关文章:

prometheus - 我应该使用 Prometheus 作为日志聚合器吗?

grafana - 如何编写返回标签值的Prometheus查询?

azure - 普罗米修斯。 CPU 处理时间总计 %

filter - prometheus 按day_of_week过滤范围向量

prometheus - 如何在 Prometheus 中为磁盘空间配置警报

spring - Prometheus UI,Spring Boot 应用程序的 Grafana 设置

networking - 使用 Prometheus 和 Grafana 的网络传输速度(以 MB/秒为单位)

prometheus - 设置 PromQL 值的格式

prometheus - PromQL:rate() 函数的用途是什么?