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