【问题标题】:How to use federation to collect Prometheus' metrics from multiple Prometheus instances (each using instance="localhost:9090")如何使用联合从多个 Prometheus 实例(每个使用 instance="localhost:9090")中收集 Prometheus 的指标
【发布时间】:2016-08-03 05:18:28
【问题描述】:

我们有多个在数据中心运行的 Prometheus 实例(我将它们称为 DC Prometheus 实例)和一个额外的 Prometheus 实例(我们在下文中将其称为“main”),我们从 DC 收集指标Prometheus 实例使用联合功能。

主 Prometheus 正在从其自身以及 DC Prometheus 实例(每个从 localhost:9090 抓取)中抓取 {job='prometheus'} 值。

问题是 Main prometheus 抱怨样本乱序:

WARN[1585] 提取无序样本时出错 numDropped=369 source=target.go:475 target=dc1-prometheus:443

我发现这是因为在 'match[]' 参数中包含了{job="prometheus"}

我正在尝试通过重新标记标签来解决这个问题,但是当我尝试使用单个 DC Prometheus 并不断更换时,我无法让它工作(我仍然遇到无序样本错误),而且我什至不知道在使用多个目标时该用什么来代替。

  - job_name: 'federate'
    scrape_interval: 15s

    honor_labels: true
    metrics_path: '/prometheus/federate'
    scheme: 'https'

    params:
      'match[]':
        - '{job="some-jobs-here..."}'
        - '{job="prometheus"}'

    relabel_configs:
    - source_labels: ['instance']
      target_label: 'instance'
      regex: 'localhost:9090'
      replacement: '??' # I've tried with 'dc1-prometheus:9090' and single target only.. no luck

    target_groups:
      - targets:
        - 'dc1-prometheus'
        - 'dc2-prometheus'
        - 'dc3-prometheus'

我的问题是如何使用 relabel_configs 来摆脱乱序错误。我到处都在使用 Prometheus 0.17。

【问题讨论】:

    标签: prometheus


    【解决方案1】:

    您需要在这里做的是在每个数据中心 Prometheus 服务器上指定唯一的external_labels。这将导致他们在 /federate 端点上添加这些标签,并防止您遇到冲突的时间序列。

    我关于联合 Prometheus 的博文中有一个类似这样的例子:http://www.robustperception.io/scaling-and-federating-prometheus/

    (我应该补充一点,relabel_configs 在这里帮不了你,因为这只会改变目标标签。metric_relabel_configs 会改变从抓取中返回的内容。请参阅http://www.robustperception.io/life-of-a-label/

    【讨论】:

    • 非常感谢。这看起来很有希望,我会试一试!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-18
    • 1970-01-01
    • 2021-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多