我们有多个在数据中心运行的 Prometheus 实例(我将它们称为 DC Prometheus 实例)和一个额外的 Prometheus 实例(我们在下文中将其称为“主”),我们通过以下方式从 DC Prometheus 实例中收集指标使用联合功能。
主要 Prometheus 正在从自身中抓取 {job='prometheus'} 值,但也从 DC Prometheus 实例(每个从 localhost:9090 中抓取)。
问题是主要普罗米修斯抱怨无序样本:
WARN[1585] 摄取无序样本时出错 numDropped=369 source=target.go:475 target=dc1-prometheus:443
我发现这是因为包含{job="prometheus"}
在 'match[]' 参数中。
我试图通过标签重新标记来解决这个问题,但是当我尝试使用单个 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。