簡介
Prometheus Federation
允許一臺 Prometheus Server
從另一臺 Prometheus Server
刮取選定的時間序列資料。對於Prometheus
的 Federation
有不同的使用方式,一般分爲Cross-service federation
與Hierarchical federation
。
Cross-service federation
Hierarchical federation
配置
在一個prometheus
的配置文件prometheus.yml
寫入以下內容。
scrape_configs:
- job_name: 'federate'
scrape_interval: 15s
honor_labels: true
metrics_path: '/federate'
params:
'match[]':
- '{job="prometheus"}'
- '{__name__=~"job:.*"}'
- '{job=~"prometheus.*"}'
- '{job="docker"}'
- '{job="node"}'
static_configs:
- targets:
- 'source-prometheus-1:9090'
- 'source-prometheus-2:9090'
- 'source-prometheus-3:9090'
- 當設置
Federation
時,將通過params
中的macth[]
參數指定需要刮取的時間序列job
,match[]
必須是一個job
選擇器,如up
或者{job="api-server"}
等。 - 設定
honor_labels
是避免監控指標衝突。 targets
下指定目標prometheus
。