【Prometheus Pushgateway】 推送数据踩坑
文章目錄
- pushed metrics are invalid or inconsistent with existing metrics: collected metric
- python prometheus_client 批量push to pushgateway
- 計算 prometheus 需要的理論內存大小
- 度量指標值 只允許 數字類型
- 度量指標值為 只能接受最長16位,16位之后數字轉為 0
- pushgateway 數據持久化
- prometheus 官網解釋
- 度量標簽和標簽命名
- 度量標準名稱和標簽數據模型
- exceeded maximum resolution of 11,000 points per timeseries. Try decreasing the query resolution
- docker-compose restart 不會生效新改的docker-compose.yml
- 開啟熱更新
- Blackbox_exporter 提示報錯:Timeout reading from socket
- Pushgateway Delete Group 報錯:Deleting metric group failed: Bad Request
- PushGateway 推送及 Prometheus 拉取時間設置
概述:
由于Prometheus數據采集基于Pull模型進行設計,因此在網絡環境的配置上必須要讓Prometheus Server能夠直接與Exporter進行通信。當這種網絡需求無法直接滿足時,就可以利用PushGateway來進行中轉。
可以通過PushGateway將內部網絡的監控數據主動Push到Gateway當中。
而Prometheus Server則可以采用同樣Pull的方式從PushGateway中獲取到監控數據。
優點:可以像老牌監控一樣運維人員可以通過 shell python 腳本自定義監控上報給PushGateway在上報給PrometheusServer,比編寫Exporters簡單
缺點:當監控項和被監控服務器數量增多,可能會有并發問題使上bao數據相對便慢
pushed metrics are invalid or inconsistent with existing metrics: collected metric
嘗試推送一個空的指標,當您嘗試一次推送相同的指標兩次時,會發生此問題。示例向該指標中添加了多個帶有相同標簽的樣本,或者如果Pushgateway重新啟動,您將無法發送相同的指標再次,您必須先將其刪除。
參見:https : //github.com/prometheus/pushgateway/blob/master/README.md
狀態碼為400
python prometheus_client 批量push to pushgateway
https://github.com/liyuanjun/prometheus-python-tutorial/blob/master/exporting/export_pushgateway.py
計算 prometheus 需要的理論內存大小
https://www.robustperception.io/how-much-ram-does-prometheus-2-x-need-for-cardinality-and-ingestion
度量指標值 只允許 數字類型
報錯text format parsing error in line 1: expected float as value, got “1.1.1.1”
原因:
為了可以更好地畫圖,所以只允許返回 數字類型 指標值
參考鏈接: https://github.com/prometheus/prometheus/issues/2227
度量指標值為 只能接受最長16位,16位之后數字轉為 0
“FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF”:340282366920938463463374607431768211455$ echo ipaddr 340282366920938463463374607431768211455 \ curl --data-binary @- -g http://ip:9090/metrics/job/pushgateway/instance/test實際結果: ipaddr{instance="test"} 340282366920938500000000000000000000000pushgateway 數據持久化
為了防止 pushgateway 重啟或意外掛掉,導致數據丟失,我們可以通過 -persistence.file 和 -persistence.interval 參數將數據持久化下來。
prometheus 官網解釋
度量標簽和標簽命名
度量標準名稱和標簽數據模型
exceeded maximum resolution of 11,000 points per timeseries. Try decreasing the query resolution
當執行 該操作時:
GET http://xxx/prometheus/api/v1/query_range?query=bps{mac=~‘xx:xx:xx:xx:xx:xx’}&start=2019-09-19T09:29:26Z&end=2019-09-20T09:29:26Z&step=15s&timeout=60s
原因:prometheus 為每個查詢設置了11k數據點的硬限制。
參考鏈接:
https://github.com/prometheus/prometheus/issues/1968
https://github.com/prometheus/prometheus/issues/2253
docker-compose restart 不會生效新改的docker-compose.yml
必須 docker-compose down然后 docker-compose up開啟熱更新
從 2.0 開始,hot reload 功能是默認關閉的,
如需開啟,需要在啟動 Prometheus 的時候,添加 --web.enable-lifecycle 參數
Blackbox_exporter 提示報錯:Timeout reading from socket
解決方法: 重啟 blackbox 容器Pushgateway Delete Group 報錯:Deleting metric group failed: Bad Request
如果 key="", 會報錯Deleting metric group failed: Bad Request 解決: 對每個KEY 設置默認值,保證每一個 key 都有值PushGateway 推送及 Prometheus 拉取時間設置
Prometheus 每次從 PushGateway 拉取的數據,并不是拉取周期內用戶推送上來的所有數據,而是最后一次 Push 到 PushGateway 上的數據,
所以推薦設置推送時間小于或等于 Prometheus 拉取的時間,這樣保證每次拉取的數據是最新 Push 上來的。
總結
以上是生活随笔為你收集整理的【Prometheus Pushgateway】 推送数据踩坑的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【MySQL】 日 常 整 理 记 录
- 下一篇: 【Docker】日常记录