prometheus pushgateway
pushgateway是prometheus的一個元件,prometheus server預設是通過exporter主動擷取資料(預設采取pull拉取資料),pushgateway則是通過被動方式推送資料到prometheus server,使用者可以寫一些自定義的監控腳本把需要監控的資料發送給pushgateway, 然後pushgateway再把資料發送給prometheus server
prometheus 預設采用定時pull 模式拉取targets資料,但是如果不在一個子網或者防火牆,prometheus就拉取不到targets資料,是以可以采用各個target往pushgateway上push資料,然後prometheus去pushgateway上定時pull資料
在監控業務資料的時候,需要将不同資料彙總, 彙總之後的資料可以由pushgateway統一收集,然後由 prometheus 統一拉取。
1)prometheus拉取狀态隻針對 pushgateway, 不能對每個節點都有效;
2)pushgateway出現問題,整個采集到的資料都會出現問題
3)監控下線,prometheus還會拉取到舊的監控資料,需要手動清理 pushgateway不要的資料。
1)安裝pushgateway
此時pushgateway上還沒有資料
2)修改prometheus-alertmanager-cfg.yaml檔案,添加job
3)測試發送資料
把資料上報到pushgateway,在被監控服務所在的機器配置資料上報,想要把192.168.40.181這個機器的記憶體資料上報到pushgateway
1)編寫shell腳本
2)打開pushgateway web ui界面,可看到如下
3)打開prometheus ui界面,可看到如下node_memory_usages的metrics名額
4)設定計劃任務,定時上報資料
作者:lawrence
-------------------------------------------
個性簽名:獨學而無友,則孤陋而寡聞。做一個靈魂有趣的人!
掃描上面二維碼關注我
本文版權歸作者所有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接配接.