联邦模式配置
1.prometheus联邦模式架构概述
默认情况下,prometheus采集的数据会存储到本地,这意味者prometheus在这种工作模式下,可能会存在单机存储的瓶颈。为了解决prometheus对于数据的采集压力,我们可以采用联邦模式来部署prometheus。
这里 91,92,93 节点分别对应本篇的 211,212,213 节点
2.部署Prometheus的集群环境
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| 1. 212,213节点部署Prometheus 略,步骤见01-Prometheus介绍及部署
`212节点` 2. 212节点配置Prometheus [root@elk02:1 ~]# vim /softwares/prometheus-2.53.2.linux-amd64/prometheus.yml ··· - job_name: 'file-sd-discovery-212' file_sd_configs: - files: - /softwares/prometheus-2.53.2.linux-amd64/file-sd.yaml
3. 编写Prometheus的基于文件服务的发现 [root@elk02:0 ~]# cat > /softwares/prometheus-2.53.2.linux-amd64/file-sd.yaml <<EOF - targets: - 10.0.0.211:9100 labels: "tag": "elk01" "apps": "yaml" EOF
4. 检查Prometheus语法 [root@elk02:0 ~]# /softwares/prometheus-2.53.2.linux-amd64/promtool check config /softwares/prometheus-2.53.2.linux-amd64/prometheus.yml
5.Prometheus热加载 [root@elk02:0 ~]# curl -X POST http://10.0.0.212:9090/-/reload
6.访问Prometheus的WebUI http://10.0.0.212:9090/targets?search=
`213节点` 1. 213 节点配置Prometheus [root@elk03:1 ~]# vim /softwares/prometheus-2.53.2.linux-amd64/prometheus.yml ··· - job_name: 'file-sd-discovery-212' file_sd_configs: - files: - /softwares/prometheus-2.53.2.linux-amd64/file-sd.yaml
2.编写Prometheus的基于文件服务的发现 [root@elk03:0 ~]# cat > /softwares/prometheus-2.53.2.linux-amd64/file-sd.yaml <<EOF - targets: - 10.0.0.212:9100 - 10.0.0.213:9100 labels: "tag": "elk02/03" "apps": "yaml" EOF
3. 检查Prometheus语法 [root@elk03:0 ~]# /softwares/prometheus-2.53.2.linux-amd64/promtool check config /softwares/prometheus-2.53.2.linux-amd64/prometheus.yml
4.Prometheus热加载 [root@elk03:0 ~]# curl -X POST http://10.0.0.213:9090/-/reload
5.访问Prometheus的WebUI http://10.0.0.213:9090/targets?search=
|
3.修改211节点配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| 1.修改Prometheus配置文件 [root@elk01:0 ~]# vim /softwares/prometheus-2.53.2.linux-amd64/prometheus.yml ··· - job_name: "prometheus-federate-212" metrics_path: "/federate" honor_labels: true params: "match[]": - '{job="promethues"}' - '{__name__=~"job:.*"}' - '{__name__=~"node.*"}' static_configs: - targets: - "10.0.0.212:9090"
- job_name: "prometheus-federate-213" metrics_path: "/federate" honor_labels: true params: "match[]": - '{job="promethues"}' - '{__name__=~"job:.*"}' - '{__name__=~"node.*"}' static_configs: - targets: - "10.0.0.213:9090"
2.检查Prometheus语法 3.Prometheus热加载
|
4.验证
1 2 3 4
| 213上可查询的语法(可自行访问212或者213的Prometheus的WebUI界面找到promQL语法查询放在211节点上验证) node_cpu_seconds_total{apps="yaml", cpu="0", job="file-sd-discovery-213"}
在211上查询是否有结果
|