普罗米修斯能否将目标拼凑在一起?

Can prometheus scrape targets together?

我需要 Prometheus 依次抓取多个 mongodb 出口商,以便计算有效的复制滞后。然而,目标之间存在几十秒的差异,这使得复制延迟无法计算。

作业 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

普罗米修斯不可能做到这一点...通常。

然而,利用 prometheus/pushgateway to achieve what you want. 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 实例是可能的。

然后配置 prometheus 以抓取 prometheus/pushgateway 而不是 mongo 导出器,并且由于所有指标都在一个端点中,因此它们希望始终保持同步并避免任何延迟迄今为止。

希望对您有所帮助。

这是不可能的,Prometheus 不保证抓取或规则评估的阶段。这也不是你应该依赖的东西,因为它非常脆弱。

我的目标是了解刮擦间隔内的滞后,而不是试图让它完美。您通常关心复制是否完全中断,而不是它是否稍微延迟。心跳作业也有帮助。