第一步:安裝promethues
1.prometheus 的下載地址
https://prometheus.io/download/#prometheus
2.下載,上傳到服務(wù)器
3解壓tar -zxvf ./prometheus-2.28.0.linux-amd64.tar.gz
4.啟動(dòng)pormetheus
/prometheus --config.file=prometheus.yml
5..http://ip:9090 查看圖形界面

## 第二部,安裝圖形界面
1.下載地址:
https://grafana.com/grafana/download/7.4.5?platform=linux
下載下來(lái)手動(dòng)導(dǎo)入。
2.第二種在線安裝比較慢:
mkdir grafana
wget https://dl.grafana.com/oss/release/grafana-7.4.5-1.x86_64.rpm
sudo yum install grafana-7.4.5-1.x86_64.rpm
安裝完成之后使用啟動(dòng)命令:
systemctl start grafana-server
systemctl status grafana-server
systemctl stop grafana-server
訪問(wèn)界面在瀏覽器中訪問(wèn)grafana:http://ip:3000(默認(rèn)賬號(hào)密碼為admin)

第三部 安裝node-export
1.下載地址
2.上傳到服務(wù)器
3. tar -zxvf? 解壓文件
[root@iz2ze4cwp14hjrk1xbz06kz software]# cd ./node_exporter-1.1.2.linux-amd64
[root@iz2ze4cwp14hjrk1xbz06kz node_exporter-1.1.2.linux-amd64]# ls
LICENSE? node_exporter? nohup.out? NOTICE
執(zhí)行啟動(dòng)方法
[root@iz2ze4cwp14hjrk1xbz06kz node_exporter-1.1.2.linux-amd64]#nohup? ./node_exporter &
4.進(jìn)入?prometheus.yml 添加如下代碼,以便于,可以監(jiān)聽(tīng)到node_export

5.proetheus的監(jiān)控到node_export

第四步:搭建 aletrmanager
1.下載地址
下載安裝Alertmanager:
https://github.com/prometheus/alertmanager/releases
[root@iz2ze4cwp14hjrk1xbz06kz software]# tar -zxvf ./alertmanager-0.19.0.linux-amd64
[root@iz2ze4cwp14hjrk1xbz06kz alertmanager-0.19.0.linux-amd64]# ls
alertmanager? alertmanager.yml? amtool? data? LICENSE? nohup.out? NOTICE
//啟動(dòng)
[root@iz2ze4cwp14hjrk1xbz06kz alertmanager-0.19.0.linux-amd64]# nohup ./alertmanager --config.file=alertmanager.yml &

alertmanager的告警的設(shè)置:
Alertmanager是一個(gè)獨(dú)立的告警模塊,接收Prometheus等客戶(hù)端發(fā)來(lái)的警報(bào),之后通過(guò)分組、刪除重復(fù)等處理,并將它們通過(guò)路由發(fā)送給正確的接收器。
Prometheus的警報(bào)分為兩個(gè)部分。Prometheus服務(wù)器中的警報(bào)規(guī)則將警報(bào)發(fā)送到Alertmanager。該Alertmanager 然后管理這些警報(bào),包括沉默,抑制,聚集和通過(guò)的方法,如電子郵件發(fā)出通知,對(duì)呼叫通知系統(tǒng),以及即時(shí)通訊平臺(tái)。
設(shè)置警報(bào)和通知的主要步驟:
1) 設(shè)置并配置Alertmanager;
2) 配置Prometheus對(duì)Alertmanager訪問(wèn);
3) 在普羅米修斯創(chuàng)建警報(bào)規(guī)則;
Alert的三種狀態(tài):
1) pending:警報(bào)被激活,但是低于配置的持續(xù)時(shí)間。這里的持續(xù)時(shí)間即rule里的FOR字段設(shè)置的時(shí)間。改狀態(tài)下不發(fā)送報(bào)警。
2) firing:警報(bào)已被激活,而且超出設(shè)置的持續(xù)時(shí)間。該狀態(tài)下發(fā)送報(bào)警。
3) inactive:既不是pending也不是firing的時(shí)候狀態(tài)變?yōu)閕nactive
prometheus觸發(fā)一條告警的過(guò)程:

https://prometheus.io/docs/prometheus/latest/configuration/unit_testing_rules/
rule例子:https://www.cnblogs.com/galsnag/articles/13202110.html
rules的自己的例子
鏈接: https://pan.baidu.com/s/1zZ0ttBAC0M57VDAvYPFCDw 提取碼: stq2
配置rule文件



重新啟動(dòng)一下服務(wù)就可以了
過(guò)段時(shí)間,補(bǔ)上郵箱提醒功能,以及influexdb與jemter的整合
至此,所有的配置都已經(jīng)完善了