Prometheus Metric Type詳解


Counter

計數器是一個累積量度,代表一個單調遞增的計數器,其值只能在重新啟動時增加或重置為零。 例如,您可以使用計數器來表示已處理請求,已完成任務或錯誤的數量。

Gauge

Gauge是一種度量標准,代表可以任意上下波動的單個數值。通常用於測量值,例如溫度或當前的內存使用量,還用於可能上升和下降的“計數”,例如並發請求數。

Histogram

直方圖對觀察值(通常是請求持續時間或響應大小之類的東西)進行采樣,並將其計數在可配置的存儲桶中。 它還提供所有觀察值的總和。

示例

nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="0.005"} 18551
nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="0.01"} 18614
nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="0.025"} 18616
nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="0.05"} 18619
nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="0.1"} 18628
nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="0.25"} 18634
nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="0.5"} 18634
nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="1"} 18634
nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="2.5"} 18634
nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="5"} 18635
nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="10"} 18635
nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="+Inf"} 18635
nginx_log_http_response_time_seconds_hist_sum{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024"} 47.625000000006324
nginx_log_http_response_time_seconds_hist_count{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024"} 18635

上面的數據展示的是某個時間點nginx_test_service服務的統計情況,其中請求的總數量為18635(nginx_log_http_response_time_seconds_hist_count對應的值),請求總的耗時為47.625000000006324s(nginx_log_http_response_time_seconds_hist_sum對應的值),每個bucket對應的為某一個區間的請求數量,如

nginx_log_http_response_time_seconds_hist_bucket{method="GET",service="nginx_test_service",status="405",upstream_addr="10.191.2.171:8024",le="0.005"} 18551 表示請求耗時小於等於0.005s的請求數量為18551,其他可以類推。

Summary

類似於直方圖,Summary會采樣觀察結果(通常是請求持續時間和響應大小之類的東西)。 盡管它還提供了觀測值的總數和所有觀測值的總和,但它可以計算滑動時間窗口內的可配置分位數。

nginx_log_http_response_time_seconds{method="POST",service="nginx_test_service_v2",status="200",upstream_addr="10.191.2.170:8033",quantile="0.5"} 0.161
nginx_log_http_response_time_seconds{method="POST",service="nginx_test_service_v2",status="200",upstream_addr="10.191.2.170:8033",quantile="0.9"} 0.247
nginx_log_http_response_time_seconds{method="POST",service="nginx_test_service_v2",status="200",upstream_addr="10.191.2.170:8033",quantile="0.99"} 0.35
nginx_log_http_response_time_seconds_sum{method="POST",service="nginx_test_service_v2",status="200",upstream_addr="10.191.2.170:8033"} 52611.560999999776
nginx_log_http_response_time_seconds_count{method="POST",service="nginx_test_service_v2",status="200",upstream_addr="10.191.2.170:8033"} 278036

上面的數據展示的是某個時間點nginx_test_service_v2服務的統計情況,其中請求的總數量為278036(nginx_log_http_response_time_seconds_count對應的值),請求總的耗時為52611.560999999776s(nginx_log_http_response_time_seconds_sum對應的值), **quantile="0.5"}**表示耗時小於0.161s的請求數占總數的50%,**quantile="0.9"} 0.247**表示耗時小於0.247s的請求數占總數的90%

Reference

https://prometheus.io/docs/concepts/metric_types/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM