Prometheus監控之Blackbox Exporter

w787815發表於2024-11-27

先安裝環境:

連結:https://pan.baidu.com/s/1xzyoDLnvs8OTq9nLopU32A 提取碼:jz6m

安裝 Prometheus

cd /usr/local/src
tar -zxvf prometheus.tar.gz
cp -R prometheus-2.45.3.linux-amd64 /usr/local/prometheus

vim /usr/lib/systemd/system/prometheus.service

[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
 
[Service]
Type=simple
User=root
WorkingDirectory=/usr/local/prometheus
ExecStart=/usr/local/prometheus/prometheus
Restart=on-failure
 
[Install]
WantedBy=multi-user.target
啟動服務和設定開機自動啟動
systemctl daemon-reload
systemctl enable prometheus.service
systemctl start prometheus.service

瀏覽器訪問 http://192.168.230.130:9090/targets?search=

安裝 Grafana

yum install -y grafana.rpm
 
 
systemctl enable grafana-server
systemctl start grafana-server

在瀏覽器訪問地址:http://192.168.230.130:3000/ ,預設密碼:admin/admin

安裝 node_exporter

tar -zxvf node_exporter-1.6.1.linux-amd64.tar.gz
cp -R node_exporter-1.6.1.linux-amd64 /usr/local/node_exporter

vim /usr/lib/systemd/system/node_exporter.service

[Unit]
Description=node_exporter
After=network.target
 
[Service]
Type=simple
User=root
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
 
[Install]
WantedBy=multi-user.target
設定開機自動啟動
 
systemctl daemon-reload
systemctl enable node_exporter.service
systemctl start node_exporter.service

監控主機

編輯 prometheus.yml

    static_configs:
      - targets: ["localhost:9090"]
  - job_name: "linux"
    static_configs:
      - targets: ["127.0.0.1:9100"]
        labels:
          instance: localhost

相關文章