多client向同一个pushgateway推送指标被覆盖问题

问题:

多个client向同一个pushgateway推送指标,每个client推送的指标名称相同但是lable不同。如下:

bash 复制代码
# TYPE ObjectCount gauge
ObjectCount{server_id="server1"} 4
ObjectCount{server_id="server2"} 4
ObjectCount{server_id="server3"} 0

推送地址如下:

bash 复制代码
http://192.168.0.1/metrics/job/test

结果从pushgateway处只能查询其中一个client推送的指标,推测时发生了覆盖。

原因:

根据官方文档描述

Pushed metrics are managed in groups, identified by a grouping key of any number of labels, of which the first must be the job label.

grouping key是这些metrics的唯一标识,grouping key实际上就是若干个label的组合。

也就是说上述指标都推送到http://192.168.0.1/metrics/job/test,会被pushgateway认为是同一组指标的多次推送,所以发生了覆盖。

解决:

每个client需要推送到独立的url上,即每个client的grouping key需要不一样。例如三个client的推送URL改为:

bash 复制代码
http://192.168.0.1/metrics/job/test/server_id/server1

http://192.168.0.1/metrics/job/test/server_id/server2

http://192.168.0.1/metrics/job/test/server_id/server3

问题便可迎刃而解

参考:

解决pushgateway数据多次推送会覆盖的问题_pushgateway 数据覆盖-CSDN博客

the same metric with different labels override each other · Issue #65 · prometheus/pushgateway · GitHub

GitHub - prometheus/pushgateway: Push acceptor for ephemeral and batch jobs.

相关推荐
秦渝兴1 天前
MySQL容器部署Prometheus+Granfana全流程
grafana·prometheus
布史2 天前
Prometheus Python Client 实操指南:从零实现自定义 Exporter
网络·python·prometheus
Yu_摆摆4 天前
windows部署prometheus+windows_exporter+grafana+alertmanager实现监控CPU、内存、磁盘并邮件告警
windows·grafana·prometheus
indexsunny6 天前
互联网大厂Java面试实战:从Spring Boot到微服务架构的深度解析
java·spring boot·spring cloud·kafka·prometheus·security·microservices
**蓝桉**6 天前
Prometheus的服务发现机制
服务发现·prometheus
**蓝桉**7 天前
prometheus监控docker容器(Rocky9)
docker·容器·prometheus
j200103227 天前
Prometheus
k8s·prometheus
lpruoyu7 天前
【云原生】可观测性系统—Prometheus—EFK
云原生·prometheus
**蓝桉**7 天前
Pushgateway的使⽤
grafana·prometheus
**蓝桉**8 天前
prometheus监控nginx
nginx·elasticsearch·prometheus