元件
說明
備注
prometheus
很火的獨立開源監控告警項目
https://prometheus.io/
alertmanager
alertmanager管理報警資訊
https://prometheus.io/docs/alerting/latest/alertmanager/
pushgateway
資訊收集中轉站進行資料上報采集
https://github.com/prometheus/pushgateway
prometheusalert
開源運維告警中心消息轉發系統
https://github.com/feiyu563/prometheusalert
飛書
辦公協作産品
https://open.feishu.cn/document/uktmuktmuktm/uujnz4sn2mjl1yzm
這裡僅僅為了快速測試和驗證功能,是以采用單容器 run 的,生産環境慎用!!
友善我們後期做報警測試,這裡也是使用容器部署。
在prometheus伺服器端修改配置檔案:
重新開機 prometheus 容器:
驗證是否擷取到資料,在浏覽器輸入:<code>http://your-ip:9090/</code>
建立配置檔案:
檢視alertmanager容器ip位址,用于配置prometheus對接接口:
修改prometheus配置檔案對接alertmanager:
配置告警規則:
重新開機prometheus容器:
驗證是否收到告警微信資訊,我們将node_exporter關閉,在被監控的伺服器操作:
然後重新整理prometheus的頁面,檢視alerts菜單,我們發現nodedown規則處于pending狀态,等待一分鐘後再次重新整理檢視,已經變成了firing狀态,這時候我們去檢視微信資訊:
說明已經收到了告警資訊。現在我們把它恢複,然後我們就收到了服務恢複的告警郵件:
由于<code>pushgateway</code>在公司k8s叢集上已經部署,我這裡直接使用,具體部署yaml如下:
在prometheus伺服器端添加配置檔案:
驗證 pushgateway 狀态,浏覽器登入prometheus,檢視status --> targets:
這部分詳見:kubernetes中部署prometheusalert并使用mysql作後端存儲,這裡僅僅為了測試,可将原文中後端存儲預設使用sqlite3。
到這裡,我們已經把基礎容器環境部署完畢,後面将測試和驗證:
(1)alertmanager結合prometheusalert模闆做基于标簽路由分發;
(2)pushgateway自定義名額監控和使用prometheusalert自定義模闆;
(3)不同通知,告警情況下prometheusalert自定義模闆使用比較;
prometheus監控系列二 | docker容器化部署實戰