prometheus聯邦federation

簡介

Prometheus Federation 允許一臺 Prometheus Server 從另一臺 Prometheus Server 刮取選定的時間序列資料。對於PrometheusFederation 有不同的使用方式,一般分爲Cross-service federationHierarchical 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[] 參數指定需要刮取的時間序列jobmatch[] 必須是一個job選擇器,如 up或者 {job="api-server"} 等。
  • 設定honor_labels是避免監控指標衝突。
  • targets下指定目標prometheus
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章