prometheus監控實戰

第一節、環境和軟件版本1.1、操作系統環境主機ip操作系統部署軟件備注192.168.10.10Centos7.9Grafana、Pushgateway、Blackbox Exporter監控ui192.168.10.11Centos7.9Loki日志存儲192.168.10.12Centos7.9Promethues存儲監控指標192.168.10.13Centos7.9logstash日志過濾192.168.10.14Centos7.9Filebeat、node_exporter日志和監控指標采集192.168.10.15Windows server2016Filebeat、node_exporter日志和監控指標采集1.2、軟件版本軟件名稱版本備注grafana8.3.3監控uiLoki2.5.0日志存儲promethues2.32.1監控指標存儲pushgateway1.4.2接收自定義監控指標filebeat6.4.3日志采集客戶端node_exporter1.3.1監控指標采集客戶端logstash7.16.2日志過濾Blackbox Exporter0.19.0監控網站、http\tcp\udp等1.3、系統初始化1、關閉防火墻
systemctl stop firewalldsystemctl disable firewalld2、關閉selinux
setenforce 0vim /etc/selinux/configSELINUX=disabled1.4、架構圖

prometheus監控實戰

文章插圖
第二節、監控平臺部署2.1、服務端部署1、grafana提示:主機192.168.10.10操作安裝
tar -xvf grafana-8.3.3.linux-amd64.tarcd grafana-8.3.3/啟動
nohup ./bin/grafana-server > ./log/grafana.log &瀏覽器訪問:http://192.168.10.10:3000用戶名和密碼:admin/admin
prometheus監控實戰

文章插圖
2、promethues提示:主機192.168.10.12操作安裝
tar -xvf prometheus-2.32.1.linux-amd64.tarcd prometheus-2.32.1.linux-amd64/啟動
nohup ./prometheus --config.file=./prometheus.yml --web.listen-address=:49800 1>nohup.log 2>&1 &瀏覽器訪問:http://192.168.10.12:49800
prometheus監控實戰

文章插圖
3、grafana集成promethues在grafana添加數據源promethues,具體步驟如圖
prometheus監控實戰

文章插圖

prometheus監控實戰

文章插圖

prometheus監控實戰

文章插圖
prometheus監控實戰

文章插圖
prometheus監控實戰

文章插圖
2.2、客戶端部署1、linuxx系統
  • 安裝部署node_exporter,解壓tar包即可
tar -xvf node_exporter-1.3.1.linux-amd64.tar.gzcd node_exporter-1.3.1.linux-amd64/
  • 啟動
nohup ./node_exporter --web.listen-address=:49999 --log.format=logfmt --collector.textfile.directory=./collection.textfile.directory/ --collector.ntp.server-is-local  >/dev/null &2、windows系統
  • 安裝Widows安裝解壓即可
    prometheus監控實戰

    文章插圖
  • 編寫啟動腳本startNode.bat
start /b "" .\windows_exporter-0.17.0-amd64.exe --telemetry.addr=":9182" --collector.textfile.directory="./collection.textfile.directory/"
  • 啟動雙擊啟動腳本即可,如下圖
    prometheus監控實戰

    文章插圖
3、配置promethues
  • 編寫配置文件vi prometheus.yml
  - job_name: "NODE"    static_configs:      - targets: ['192.168.10.14:49999']        labels:          env: prd001          group: PAAS          hostip: 192.168.10.14      - targets: ['192.168.10.15:9182']        labels:          env: prd001          group: PAAS          hostip: 192.168.10.15
  • 重啟promethues
nohup ./prometheus --config.file=./prometheus.yml --web.listen-address=:49800 1>nohup.log 2>&1 &