1.prometheus安裝
軟件下載:
wget https://dl.grafana.com/oss/release/grafana-6.4.2-1.x86_64.rpm
https://github.com/prometheus/prometheus/releases/download/v2.13.0/prometheus-2.13.0.linux-amd64.tar.gz
wget https://golang.org/doc/install?download=go1.13.1.linux-amd64.tar.gz
說明:虛擬機Centos7 環境下進行安裝.
1.1環境裝備
配置golang的環境
wget https://golang.org/doc/install?download=go1.13.1.linux-amd64.tar.gz
tar -C /usr/local/ -xvf go1.13.1.linux-amd64.tar.gz
添加到環境變量中
vim /etc/profile
export PATH=$PATH:/usr/local/go/bin
重載環境變量
source /etc/profile
查看版本
go version
1.2安裝Prometheus
tar -C /usr/local/ -xvf prometheus-2.13.0.linux-amd64.tar.gz
ln -sv /usr/local/prometheus-2.13.0.linux-amd64/ /usr/local/prometheus
啟動:
/usr/local/prometheus/prometheus --storage.tsdb.path=/data/ --config.file=/usr/local/prometheus/prometheus.yml
暫時關閉防火牆
systemctl stop firewalld.service
登錄:http://192.168.31.91:9090
1.3安裝Grafana
rpm -ivh --nodeps grafana-6.4.2-1.x86_64.rpm
啟動:
systemctl daemon-reload
systemctl enable grafana-server.service
systemctl start grafana-server.service
登錄:http://192.168.31.91:3000/login 初始密碼:admin admin
安裝餅圖插件:
grafana-cli plugins install grafana-piechart-panel
注意Grafana 密碼重置
yum的安裝方式,源碼安裝方式找到grafana.db文件
sqlite3 /var/lib/grafana/grafana.db
update user set password = '59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6', salt = 'F3FAxVm33R' where login = 'admin';
1.4.配置Grafana
添加prometheus數據源
點擊主界面的“Add data source”
Dashboards頁面選擇“Prometheus 2.0 Stats”
Settings頁面填寫普羅米修斯地址並保存
如果需要告警的配置需要下載alertmanager
Prometheus的告警機制是server推送告警到alertmanger,配置告警規則和告警方式
插件下載地址https://github.com/prometheus/alertmanager/releases/download/v0.19.0/alertmanager-0.19.0.linux-amd64.tar.gz
具體架構圖如下:
如果在prometheus的http://localhost:9090/管理界面沒有數據同時又
No datapoints found
報錯顯示
解決方案:一定要修改服務器的時間