日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

6.prometheus数据上报方式-pushgateway

發布時間:2024/9/27 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 6.prometheus数据上报方式-pushgateway 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

6.prometheus數據上報方式-pushgateway
6.1.pushgateway下載、安裝、啟動
6.2.prometheus上配置target
6.3.push數據到pushgateway
7.參考文章

6.prometheus數據上報方式-pushgateway

參考:https://www.cnblogs.com/xiaobaozi-95/p/10684524.html

客戶端使用push的方式上報監控數據到pushgateway,prometheus會定期從pushgateway拉取數據。使用它的原因主要是:
?Prometheus 采用 pull 模式,可能由于不在一個子網或者防火墻原因,導致Prometheus 無法直接拉取各個 target數據。
?在監控業務數據的時候,需要將不同數據匯總, 由 Prometheus 統一收集。

拓撲圖

6.1.pushgateway下載、安裝、啟動

軟件包下載位置:https://prometheus.io/download/

下載包之后將包pushgateway-1.4.1.linux-amd64.tar.gz放到:cd /root/software 中。

解壓、安裝、啟動

cd /root/software tar -zxvf pushgateway-1.4.1.linux-amd64.tar.gz -C ../installed/cd /root/installed/pushgateway nohup ./pushgateway > pushgateway.file 2>&1 &

服務器上的訪問地址:
http://localhost:9091

pushgateway訪問地址:
http://localhost:19091 (使用docker映射后的端口進行訪問)

[root@node1 node_exporter]# curl localhost:9091/metrics # HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile="0"} 3.7902e-05 go_gc_duration_seconds{quantile="0.25"} 3.7902e-05 go_gc_duration_seconds{quantile="0.5"} 0.000109801 go_gc_duration_seconds{quantile="0.75"} 0.000109801 go_gc_duration_seconds{quantile="1"} 0.000109801 go_gc_duration_seconds_sum 0.000147703 go_gc_duration_seconds_count 2 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge go_goroutines 16 # HELP go_info Information about the Go environment. # TYPE go_info gauge go_info{version="go1.16.4"} 1 # HELP go_memstats_alloc_bytes Number of bytes allocated and still in use. # TYPE go_memstats_alloc_bytes gauge go_memstats_alloc_bytes 3.439648e+06 # HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed. # TYPE go_memstats_alloc_bytes_total counter go_memstats_alloc_bytes_total 4.901016e+06 # HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table. # TYPE go_memstats_buck_hash_sys_bytes gauge

6.2.prometheus上配置target

- job_name: 'push-metrics'static_configs:- targets: ['172.17.0.2:9091']labels:instance: pushgateway

6.3.push數據到pushgateway

推送URL :pushgateway默認采用9091端口,路徑:
/metrics/job/{/<LABEL_NAME>/<LABEL_VALUE>}

是job標簽的值,后面跟任意數量的標簽對,instance標簽可以有也可以沒有。

示例1(添加單條數據):
shell下執行:

echo "test_metric 2333" | curl --data-binary @- http://172.17.0.2:9091/metrics/job/test_job

執行完成之后:
A: 在http://localhost:19091/#中可以看到添加的內容。

B:在http://localhost:19090/中的輸入框中輸入test_metric,可以看到結果:
test_metric{exported_job=“test_job”, instance=“pushgateway”, job=“push-metrics”}

示例二(從文件中寫入指標數據):

/root/workspace/data.txt http_request_total{code="200",domain="abc.cn"} 276683 http_request_total{code="400",domain="abc.cn"} 0 http_request_total{code="408",domain="abc.cn"} 7 http_request_total{code="401",domain="abc.cn"} 0 http_request_total{schema="http",domain="abc.cn"} 277725 http_request_total{schema="https",domain="abc.cn"} 0 http_request_time{code="total",domain="abc.cn"} 76335.809000 http_request_uniqip{domain="abc.cn"} 216944 http_request_maxip{clientip="172.27.0.12",domain="abc.cn"} 81

執行的命令如下:

curl -XPOST --data-binary @data.txt http://172.17.0.2:9091/metrics/job/test_job

執行完成之后,可以到prometheus中查看上面的http_request_total數據信息

7.參考文章

從零搭建Prometheus監控報警系統
https://www.cnblogs.com/chenqionghe/p/10494868.html
Prometheus告警簡介
https://www.bookstack.cn/read/prometheus-book/alert-prometheus-alert-manager-overview.md

總結

以上是生活随笔為你收集整理的6.prometheus数据上报方式-pushgateway的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。