简体   繁体   English

普罗米修斯可以将目标拼凑在一起吗?

[英]Can prometheus scrape targets together?

I need Prometheus to scrape several mongodb exporters one after another in order to compute a valid replication lag.我需要 Prometheus 一个接一个地抓取几个 mongodb 导出器,以便计算有效的复制延迟。 However, the targets are scraped with a difference of several dozen seconds between them, which makes replication lag impossible to compute.然而,目标被抓取时它们之间有几十秒的差异,这使得复制延迟无法计算。

The job yaml is below:工作 yaml 如下:

- job_name: mongo-storage
  honor_timestamps: true
  scrape_interval: 1m
  scrape_timeout: 10s
  metrics_path: /metrics
  scheme: http
  static_configs:
  - targets:
    - mongo-1a-exporter.monitor:9216
    - mongo-2a-exporter.monitor:9216
    - mongo-3a-exporter.monitor:9216
    - mongos-exporter.monitor:9216
    - mongo-1b-exporter.monitor:9216
    - mongo-2b-exporter.monitor:9216
    - mongo-3b-exporter.monitor:9216
    labels:
      cluster: mongo-storage

This isn't possible, Prometheus makes no guarantees about the phase of scrapes or rule evaluations.这是不可能的,普罗米修斯对刮擦或规则评估的阶段不做任何保证。 Nor is this something you should depend upon, as it'd be very fragile.这也不是您应该依赖的东西,因为它非常脆弱。

I'd aim for knowing the lag within a scrape interval, rather than trying to get it perfect.我的目标是了解刮擦间隔内的滞后,而不是试图使其完美。 You generally care if replication is completely broken, rather than if it's slightly delayed.您通常关心复制是否完全中断,而不是稍微延迟。 A heartbeat job could also help.心跳工作也有帮助。

This isn't possible with Prometheus... normally.这对普罗米修斯来说是不可能的......通常。

However it might be possible to exploit the prometheus/pushgateway to achieve what you want.但是,可能可以利用prometheus/pushgateway来实现您想要的。 My thinking is that you write a script/tool to scrape the mongo exporters in a synchronised way, threads/forks/whatever, and then push those metrics into a prometheus/pushgateway instance.我的想法是,您编写一个脚本/工具以同步方式、线程/分叉/任何方式抓取 mongo 导出器,然后将这些指标推送到prometheus/pushgateway实例中。

Then configure prometheus to scrape the prometheus/pushgateway instead of the mongo exporters, and since all the metrics are in the one endpoint they will hopefully always be in sync and avoid any lag regarding being up to date.然后配置 prometheus 来抓取prometheus/pushgateway而不是 mongo 导出器,并且由于所有指标都在一个端点中,因此它们有望始终保持同步并避免任何关于最新的滞后。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM