如何保证Prometheus拉取的数据是最新的,不包含拉取间隔前的旧数据

How to ensure that the data pulled by Prometheus is up-to-date and does not include old data before the pull interval

The Prometheus interval pulls data from the pushgateway. The pushgateway uses the “-persistence.file string” data persistence parameter configuration. The client sends data to the pushgateway in real time.

If Prometheus pulls data within the time interval. Pushgateway did not receive data from the client. What happens when Prometheus pulls data from the pushgateway interval?

  1. Will Prometheus pull old data outside the time interval, and then take the pull time as the time of the old data?
  2. Prometheus will judge according to the pull time interval, pushgateway no new data during this period, and then pull the data is empty?
  3. Still have other results

Pushgateway 将始终为一个组提供最新的推送(如果有的话)。如果您只关心获取最新数据,那么推送网关不适合您的用例(请参阅 https://prometheus.io/docs/practices/pushing/)。

您可能想要做的是使用直接检测,让 Prometheus 直接抓取您的应用程序。