为什么多个PushGateway可能会导致一些问题,例如数据不一致?

huangapple go评论54阅读模式
英文:

Why Multiple PushGateway may cause some problems, such as data inconsistency?

问题

"I have read an article about multiple pushgateway instances may cause data confusion. But I don't understand how it happens."

"当相同的指标数据从不同的Pushgateway实例推送时,可能会出现时间戳同步问题或数值差异,这可能会导致在Prometheus服务器上聚合指标数据时出现数据不一致。"

"The timestamp of data series collected by Prometheus depends on the Prometheus collection time. How does this relate to Pushgateway?"

"Prometheus仅将数据推送到Pushgateway。我看不出推送时间戳与收集时间戳之间的关系。"

"I'm just curious why multiple Pushgateways can cause lots of problems."

"我只是好奇为什么多个Pushgateway可能会引发很多问题。"

"Of course, my final goal is to determine whether monitoring metrics collected from one server can be uploaded to different Pushgateway instances? Or is it better to ensure that metrics from one server are uploaded to some Pushgateway instances."

"当然,我的最终目标是确定是否可以将从一个服务器收集的监控指标上传到不同的Pushgateway实例?还是更好地确保将来自一个服务器的指标上传到一些Pushgateway实例。"

英文:

I have read an article about multiple pushgateway instances may cause data confusion. But I don't understand how it happen.

"When the same indicator data is pushed from different Pushgateway instances, there may be a time stamp synchronization issue or value discrepancy, which may cause data inconsistency when aggregating indicator data on the Prometheus server."

The time stamp of data series of prometheus collected is depended on prometheus collection time. How dose this have to do with pushgateway?

Pushgateway just push data to prometheus. I don't see the relation between push time stamp and collect time stamp.

I just curious why multiple pushgateway can cause lots of problems.

Of course, my final goal is to determine whether monitoring metrics collected from one server can be uploaded to different Pushgateway instances?
Or better to ensure one server metrics be uploaded to some pushgateway instances.

答案1

得分: 1

Here are the translations for the provided content:

Pushgateway 只是将数据推送到 Prometheus。

首先,它并不推送任何内容。您需要将指标推送到 Pushgateway。后来,Prometheus通过常规的抓取作业来抓取它们。这些事件没有以任何方式同步。

I don't see the relation between push time stamp and collect time stamp.

如果您在推送时不指定时间戳,那么它们之间就没有关系。Prometheus将会将抓取时的时间戳附加到值上。官方自述文件

如果您在时间 t1 推送指标,您可能会认为 Prometheus 将以相同的时间戳 t1 抓取它们。然而,Prometheus 附加的时间戳是它抓取 Pushgateway 时的时间。

考虑以下示例:
假设指标的当前值为 300,在一段时间后,您推送了值 100,然后推送了值 200。由于您的推送和抓取没有同步,您可能会遇到以下时间线:

             推送到 p1,值为 100
             |       推送到 p2,值为 200
             v       v
-----------------------------------------------
^                         ^        ^               
之前从 p1 抓取       |        从 p1 抓取       
                          从 p2 抓取

Prometheus 视图中的值:
 300 -------------------  | 200 -- | 100 -----

我的最终目标是确定从一个服务器收集的监控指标是否可以上传到不同的 Pushgateway 实例?

最好将相同的指标推送到同一个 Pushgateway。甚至更好的做法是使用单个 Pushgateway。如果考虑到冗余性,可以使用两个实例,并使用反向代理强制镜像以进行推送。

当然,最好的解决方案始终是尽量避免使用 Pushgateway。

英文:

>Pushgateway just push data to Prometheus.

First of it doesn't push anything. You push your metrics to pushgateway. Later Prometheus scrapes them through usual scraping job. Those events are not synchronized in any way.

>I don't see the relation between push time stamp and collect time stamp.

If you don't specify timestamp when pushing, there is no relation. Prometheus will attach timestamp of scrape to the value. Official readme:

>>If you push metrics at time t1, you might be tempted to believe that Prometheus will scrape them with that same timestamp t1. Instead, what Prometheus attaches as a timestamp is the time when it scrapes the Pushgateway.

Consider following example:
Imagine current value of metric : 300, after some time you push value 100, and later 200. Since your pushes and scrapes are not synchronized you can encounter timeline like this:

             push to p1, value 100
             |       push to p2, value 200
             v       v
-----------------------------------------------
^                         ^        ^               
previous scrape from p1   |        scrape p1       
                          scrape from p2

Values as seen by Prometheus:
 300 -------------------  | 200 -- | 100 -----

>my final goal is to determine whether monitoring metrics collected from one server can be uploaded to different Pushgateway instances?

It is better to push same metrics to same pushgateway. It is even better to use single Pushgatway. If you considering this for redundancy you can use two instances with reverse proxy enforcing mirroring for pushing.

The best solution is of course as always not to use Pushgateway if possible.

huangapple
  • 本文由 发表于 2023年4月19日 22:51:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76055926.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定