【问题标题】:Prometheus for k8s multi clusters用于 k8s 多集群的 Prometheus
【发布时间】:2021-03-03 05:18:32
【问题描述】:

我有 3 个 Kubernetes 集群(产品、测试、监控)。我是 prometheus 的新手,所以我通过 helm chart 在我的测试环境中安装它来测试它:

# https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack
helm install [RELEASE_NAME] prometheus-community/kube-prometheus-stack

但是,如果我想获得来自 prod 和 test 集群的指标,我必须重复相同的 helm 安装,并且每个“kube-prometheus-stack”都将在其自己的集群中独立。这根本不理想。我正在尝试找到一种方法来拥有一个 prometheus/grafana,它可以联合/聚合来自每个集群的 prometheus 服务器的指标。

我找到了这个链接,说的是普罗米修斯联盟:

https://prometheus.io/docs/prometheus/latest/federation/

如果安装 helm chart “kube-prometheus-stack” 并在其他 2 个集群上摆脱 grafana,我如何使第三个集群上的第三个“kube-prometheus-stack”从 2其他的?
谢谢

【问题讨论】:

    标签: kubernetes prometheus


    【解决方案1】:

    您必须修改 prometheus federate 的配置,以便它可以从其他集群中抓取指标,如 in documentation 所述:

    scrape_configs:
      - job_name: 'federate'
        scrape_interval: 15s
    
        honor_labels: true
        metrics_path: '/federate'
    
        params:
          'match[]':
            - '{job="prometheus"}'
            - '{__name__=~"job:.*"}'
    
        static_configs:
          - targets:
            - 'source-prometheus-1:9090'
            - 'source-prometheus-2:9090'
            - 'source-prometheus-3:9090'
    

    params 字段检查来自的 jobs to scrape 指标。在这个特定的例子中

    它将抓取标签为 job="prometheus" 或以度量名称开头的任何系列 与工作:来自普罗米修斯服务器 源普罗米修斯-{1,2,3}:9090

    您可以查看以下文章,让您更深入地了解普罗米修斯联盟:

    1. Monitoring Kubernetes with Prometheus - outside the cluster!

    2. Prometheus federation in Kubernetes

    3. Monitoring multiple federated clusters with Prometheus - the secure way

    4. Monitoring a Multi-Cluster Environment Using Prometheus Federation and Grafana

    【讨论】:

      【解决方案2】:

      您可以尝试查看 Wavefront。它现在是一个商业工具,但您可以免费试用 30 天 - 而且,它还支持 promQL。所以本质上,您可以在所有集群中使用相同的 prometheus 规则和配置,然后使用 wavefront 连接到所有这些 prom 实例。

      另一个选项可能是灭霸,但我从未亲自使用过。

      【讨论】:

      • 不幸的是,这是针对我无法使用 Wavefront 的客户。
      猜你喜欢
      • 2019-06-28
      • 2019-04-13
      • 2019-07-13
      • 2021-10-24
      • 2019-07-18
      • 1970-01-01
      • 1970-01-01
      • 2018-10-18
      • 2020-06-26
      相关资源
      最近更新 更多