Prometheus 联邦【九】
实验拓扑图
Prometheus Server环境
192.168.40.180 xianchaomaster1 #主节点
192.168.40.181 xianchaonode1 #联邦节点1、node-exporter
192.168.40.182 xianchaonode2 #联邦节点2、node-exporter
192.168.40.130 k8s-docker #node-exporter
192.168.40.180监控=> 192.168.40.181、192.168.40.182
192.168.40.181监控=> 192.168.40.181 192.168.40.
192.168.40.182监控=> 192.168.40.182
部署Prometheus Server端
#xianchao1、xianchao2、xianchaomaster1、k8s-docker 四台需要部署Prometheus server和node-exproter
参考:https://www.cnblogs.com/birkhoffxia/articles/17275357.html
配置联邦Server 监控node-exporter
#Prometheus联邦节点1 192.168.40.181
[root@xianchaonode1 apps]# cat prometheus/prometheus.yml
- job_name: "prometheus-cluster-xianchaonode1"
static_configs:
- targets: ["192.168.40.181:9100"]
- job_name: "prometheus-cluster-k8sdocker"
static_configs:
- targets: ["192.168.40.130:9100"]
#Prometheus联邦节点2 192.168.40.182
[root@xianchaonode1 apps]# cat prometheus/prometheus.yml
- job_name: "prometheus-cluster-xianchaonode2"
static_configs:
- targets: ["192.168.40.182:9100"]
Prometheus server采集联邦Server配置并且验证
[root@xianchaomaster1 prometheus]# cat /apps/prometheus/prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
- 192.168.40.180:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
- "/apps/alertmanager/rules/rule1.yaml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
#配置联邦
- job_name: "prometheus-federate-xianchaonode1"
scrape_interval: 10s
honor_labels: true
metrics_path: '/federate'
params:
'match[]':
- '{job="prometheus"}'
- '{__name__=~"job.*"}'
- '{__name__=~"node.*"}'
static_configs:
- targets:
- '192.168.40.181:9090'
- job_name: "prometheus-federate-xianchaonode2"
scrape_interval: 10s
honor_labels: true
metrics_path: '/federate'
params:
'match[]':
- '{job="prometheus"}'
- '{__name__=~"job.*"}'
- '{__name__=~"node.*"}'
static_configs:
- targets:
- '192.168.40.182:9090'