一、安裝prometheus:
下載相應的版本 :https://prometheus.io/download/
解壓:
Linux:tar -zxvf XXX.tar.gz
windows:直接下載.ism 安裝程序
mac:未使用過
進入到解壓后的文件夾可以直接運行:
./prometheus --config.file=prometheus.yml
瀏覽器打開“http://localhost:9090” 訪問
二、配置啟動項
方法1 直接在prometheus.yml進行配置(監控內容較少的時候):
- job_name: 'linux' static_configs: - targets: ['localhost:9104']
方法2 指定配置文件 :
# prometheus.yml 配置 - job_name: 'Linux' file_sd_configs: - files: ['/opt/prometheus/sd_cfg/Linux.yml']
# /opt/prometheus/sd_cfg/Linux.yml 中文件配置 - targets: ['IP地址:9100'] labels: name: Linux-node1[這里建議給每個主機打個有意義的標簽,方便識別.]
配置文件檢查命令(檢查配置是否存在錯誤):
./promtool check config prometheus.yml
配置文件詳解:
官方文檔:https://prometheus.io/docs/prometheus/latest/configuration/configuration/
其他:
https://www.cnblogs.com/liujiliang/p/10080849.html
https://www.cnblogs.com/xiangsikai/p/11288835.html
創建專用用戶:
groupadd prometheus
useradd -g prometheus -m -d /opt/prometheus/ -s /sbin/nologin prometheus
二、配置 Linux系統監控
node_exporter 服務安裝:
下載地址:https://github.com/prometheus/node_exporter/releases/
解壓命令:tar -zxvf node_exporter-xxx.tar.gz 解壓完成 進入解壓文件夾: cd node_exporter-xxx 啟動: ./node_exporter
成功效果
三、安裝配置Grafana
下載地址:https://grafana.com/grafana/download
安裝編譯:yum localinstall grafana-xxx.rpm
安裝完成訪問 : http://localhost:3000
默認賬號/密碼:admin/admin
配置 node_exporter監控:
網址和服務名稱填寫就可以了。
添加統計圖模板:
模板網址:https://grafana.com/grafana/dashboards
找到模板ID
填寫模板ID
效果:
教程地址:https://www.cnblogs.com/guoxiangyue/p/11772717.html