10.0.0.3 | Prometheus |
10.0.0.5 | Prometheus联邦 |
10.0.0.7 | Prometheus联邦 |
10.0.0.2 | node_exporter |
10.0.0.9 | node_exporter |
10.0.0.3、10.0.0.5、10.0.0.7都安装prometheus
[root@VM-0-3-centos ~]# wget https://github.com/prometheus/prometheus/releases/download/v2.37.0/prometheus-2.37.0.linux-amd64.tar.gz -C /apps
[root@VM-0-3-centos ~]# tar xvf prometheus-2.37.0.linux-amd64.tar.gz
[root@VM-0-3-centos ~]# ln -sv /apps/prometheus-2.37.0.linux-amd64 /apps/prometheus
[root@VM-0-3-centos ~]# vim /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network.target
[Service]
Restart=on-failure
WorkingDirectory=/apps/prometheus/
ExecStart=/apps/prometheus/prometheus --config.file=/apps/prometheus/prometheus.yml --web.enable-lifecycle
[Install]
WantedBy=multi-user.target
[root@VM-0-3-centos ~]# systemctl restart prometheus
[root@VM-0-3-centos ~]# systemctl enable prometheus
10.0.0.2、10.0.0.9安装node_exporter
[root@VM-0-9-centos node_exporter]# wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz -C /apps
[root@VM-0-9-centos node_exporter]# tar -xvf node_exporter-1.3.1.linux-amd64.tar.gz
[root@VM-0-9-centos node_exporter]# ln -sv /apps/node_exporter-1.3.1.linux-amd64.tar.gz /apps/node_exporter
[root@VM-0-9-centos node_exporter]# vim /etc/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/docs/introduction/overview/
After=network.target
[Service]
Restart=on-failure
WorkingDirectory=/apps/node_exporter/
ExecStart=/apps/node_exporter/node_exporter
[Install]
WantedBy=multi-user.target
[root@VM-0-9-centos node_exporter]# systemctl restart node_exporter.service
[root@VM-0-9-centos node_exporter]# systemctl enable node_exporter.service
10.0.0.5、10.0.0.7配置prometheus.yml
vim /apps/prometheus/prometheus.yml
- job_name: "prometheus-0.9"
static_configs:
- targets: ["10.0.0.9:9100"]
vim /apps/prometheus/prometheus.yml
- job_name: "prometheus-0.2"
static_configs:
- targets: ["10.0.0.2:9100"]
systemctl restart prometheus.service
10.0.0.3配置prometheus.yml,添加联邦服务器地址
vim /apps/prometheus/prometheus.yml
- job_name: 'prometheus-federate-0.7'
scrape_interval: 10s
honor_labels: true
metrics_path: '/federate'
params:
'match[]':
- '{job="prometheus"}'
- '{__name__=~"job:.*"}'
- '{__name__=~"node.*"}'
static_configs:
- targets:
- '10.0.0.5:9090'
- job_name: 'prometheus-federate-0.5'
scrape_interval: 10s
honor_labels: true
metrics_path: '/federate'
params:
'match[]':
- '{job="prometheus"}'
- '{__name__=~"job:.*"}'
- '{__name__=~"node.*"}'
static_configs:
- targets:
- '10.0.0.7:9090'
systemctl restart prometheus.service
查看有没有联邦集群监控到的node
标签:node,10.0,exporter,centos,apps,prometheus,Prometheus,集群,联邦 From: https://www.cnblogs.com/zyyang1993/p/16621158.html