05-prometheus的联邦模式-分布式监控

本文详细介绍了如何在大型企业中使用Prometheus的联邦模式进行分布式监控,包括配置子节点监控目标、主节点的联邦聚合设置以及Grafana的数据源导入。通过实例展示了如何配置Prometheus节点以监控多个节点并整合数据到主节点上展示。
摘要由CSDN通过智能技术生成

一、联邦模式概述

1,架构介绍

由于,在大型企业中,被监控项目比较多,多到一台prometheus服务无法承载其大量的监控数据的传输,所以,联邦模式应运而生,它同等于zabbix监控的分布式,就是将大量的被监控项,分开进行监控,然后再汇总到一台prometheus的服务上。


2,学习环境介绍

 为了模拟学习环境,我们准备:

1,41和42服务器作为被监控节点,

2,  71作为grafana出图监控大屏;

3,  31作为prometheus主节点;

4,  32和33作为prometheus的从节点;

二、prometheus子节点配置

1,子节点32配置

本次学习,直接指向被监控地址,不用自动发现了;

[root@prometheus-server32 ~]# vim /prometheus/softwares/prometheus-2.37.8.linux-amd64/prometheus.yml 

# my global config
global:
  scrape_interval: 3s  
  evaluation_interval: 15s 
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]
  #直接监控41节点
  - job_name: "node-exporter-01"
    static_configs:
      - targets: ["10.0.0.41:9100"]

[root@prometheus-server32 ~]# curl -X POST http://10.0.0.32:9090/-/reload

查看浏览器验证

2,子节点33配置

[root@prometheus-server33 ~]# vim /prometheus/softwares/prometheus-2.37.8.linux-amd64/prometheus.yml 


global:
  scrape_interval: 3s 
  evaluation_interval: 15s 
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]
    #直接监控节点
  - job_name: "node-exporter-02"
    static_configs:
      - targets: ["10.0.0.42:9100"]

curl -X POST http://10.0.0.33:9090/-/reload

浏览器访问验证,是否监控成功

三、prometheus主节点配置

注意,prometheus主节点,取得是:prometheus子节点的数据;

[root@prometheus-server31 ~]# cat /prometheus/softwares/prometheus-2.37.8.linux-amd64/prometheus.yml 
global:
  scrape_interval: 3s 
  evaluation_interval: 15s 
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
scrape_configs:
  - job_name: "prometheus-32"
    metrics_path: "/federate"
    #用于解决标签冲突问题,有效值为true和false(false)
    #设置为true,保留抓取的标签以忽略服务器自身的标签,就是覆盖原来的标签;
    #设置为false,不覆盖原来的标签,而是在标签前加了一个“exporter_”前缀;
    honor_labels: true
    params:
      "match[]":
      - '{job="prometheus"}'
      - '{__name__=~"job:.*"}'
      - '{__name__=~"node.*"}'
    static_configs:
      - targets: ["10.0.0.32:9090"]
    #子节点33
  - job_name: "prometheus-33"
    metrics_path: "/federate"
    honor_labels: true
    params:
      "match[]":
      - '{job="prometheus"}'
      - '{__name__=~"job:.*"}'
      - '{__name__=~"node.*"}'
    static_configs:
      - targets: ["10.0.0.33:9090"]

[root@prometheus-server31 ~]# curl -X POST http://10.0.0.31:9090/-/reload

浏览器查看,是否监控到子节点的数据

四、grafana出图

1,添加数据源

2,导入仪表盘

3,创建

至此,联邦模式就学习完毕了;

课后,自己再通过consul网络集群或者文档的方式,再使用自动发现来构建一遍这个联邦模式;

  • 32
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

心机の之蛙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值