Prometheus Native Histogramsの現状

1.8K Views

July 23, 25

スライド概要

オブザーバビリティの最前線 from Software Design
Jagu'e'r オブザーバビリティ分科会 Meetup #3
https://jaguer-o11y-sre.connpass.com/event/359593/

profile-image

ソフトウェアエンジニア

シェア

またはPlayer版

埋め込む »CMSなどでJSが使えない場合

ダウンロード

関連スライド

各ページのテキスト
2.

⚫ ⚫ ⚫ ⚫ ⚫ ⚫ ⚫

3.

⚫ ⚫

4.

⚫ ⚫ ⚫ ⚫

6.

⚫ ⚫ ⚫ ⚫ ⚫

8.

request_duration_seconds_bucket{status="200",method="get",le="0.25"} 34 request_duration_seconds_bucket{status="200",method="get",le="0.5"} 126 request_duration_seconds_bucket{status="200",method="get",le="1"} 231 request_duration_seconds_bucket{status="200",method="get",le="2.5"} 281 request_duration_seconds_bucket{status="200",method="get",le="5"} 556 request_duration_seconds_bucket{status="200",method="get",le="10"} 621 request_duration_seconds_bucket{status="200",method="get",le="+Inf"} 5139 request_duration_seconds_sum{status="200",method="get"} 104124.3332884999982 request_duration_seconds_count{status="200",method="get"} 5231

9.

0 0.25 0.5 1 2.5 5 10 +Inf 0 1 5 10 20 50 100 +Inf

10.

duration = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Namespace: namespace, Name: "request_duration_seconds", Help: "Latencies for requests.", Buckets: []float64{.25, .5, 1, 2.5, 5, 10}, }, []string{"status", "method"}, )

11.

⚫ ⚫

12.

⚫ ⚫ ⚫ ⚫ ⚫

13.

(2 ⚫ ⚫ ⚫ ⚫ 2−𝑠𝑐ℎ𝑒𝑚𝑎 𝑖𝑛𝑑𝑒𝑥−1 ) < 𝑣 ≤ (2 2−𝑠𝑐ℎ𝑒𝑚𝑎 𝑖𝑛𝑑𝑒𝑥 )

14.

duration = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Namespace: namespace, Name: "request_duration_seconds", Help: "Latencies for requests.", NativeHistogramBucketFactor: 1.1, NativeHistogramMaxBucketNumber: 30, }, []string{"status", "method"}, ) 𝑓𝑎𝑐𝑡𝑜𝑟 = 22 −𝑠𝑐ℎ𝑒𝑚𝑎

15.

-3-2-1 0 1 2 3 4 -2-1 0 1 2 3 4 -3 -2 -1 0 1 2 3 -6-5-4-3-2-1 0 1 2 3 4 5 6 7 4

16.

-3-2-1 0 1 2 3 4 -1 0 1 2

17.
[beta]
カウント値

{
"m": {
"name": "request_duration_seconds",
"metric": [
{
"histogram": {
"sample_count": 436,
"sample_sum": 4456.33426414,
"created_timestamp": {
"seconds": 1753079608,
"nanos": 635013263
},
"schema": 2,
"zero_threshold": 2.938735877055719E-39,
"zero_count": 0,
"positive_span": [
{ "offset": -22, "length": 1 },
{ "offset": 10, "length": 30 }
],
"positive_delta": [
1,
0, 0, -1, 1, 3, -4, 1, -1, 1, 1,
2, -1, 0, 4, -1, 5, -5, -4, 10, 5,
-4, 5, 3, 14, -6, 9, 9, 14, 15, -61
]
}
}
]
}
}

20.

⚫ ⚫ App Collector Grafana

21.

⚫ ⚫ ⚫

22.
[beta]
message Histogram {
optional uint64 sample_count
= 1;
optional double sample_count_float = 4;
optional double sample_sum
= 2;
repeated Bucket bucket
= 3;
optional google.protobuf.Timestamp created_timestamp = 15;
optional sint32 schema
= 5;
optional double zero_threshold
= 6;
optional uint64 zero_count
= 7;
optional double zero_count_float = 8;
repeated BucketSpan negative_span = 9;
repeated sint64 negative_delta
= 10;
repeated double negative_count
= 11;
repeated BucketSpan positive_span = 12;
repeated sint64 positive_delta
= 13;
repeated double positive_count
= 14;

# TYPE nativehistogram histogram
# HELP nativehistogram Is a basic example of a native histogram.
nativehistogram{count:24,sum:100,schema:0,zero_threshold:0.001,z
ero_count:4,positive_spans:[0:2,1:2],negative_spans:[0:2,1:2],po
sitive_deltas:[2,1,-2,3],negative_deltas:[2,1,-2,3]}

repeated Exemplar exemplars = 16;
}
message Bucket {
optional uint64
cumulative_count
= 1;
optional double
cumulative_count_float = 4;
optional double
upper_bound
= 2;
optional Exemplar exemplar
= 3;
}
message BucketSpan {
optional sint32 offset = 1;
optional uint32 length = 2;
}

23.

⚫ ⚫ ⚫ ⚫ ⚫ (22 −𝑠𝑐ℎ𝑒𝑚𝑎 )𝑖𝑛𝑑𝑒𝑥−1 < 𝑣 ≤ (22 (22 −𝑠𝑐𝑎𝑙𝑒 −𝑠𝑐ℎ𝑒𝑚𝑎 )𝑖𝑛𝑑𝑒𝑥 < 𝑣 ≤ (22 )𝑖𝑛𝑑𝑒𝑥 −𝑠𝑐𝑎𝑙𝑒 )(𝑖𝑛𝑑𝑒𝑥+1)

24.

⚫ ⚫ ⚫

25.

⚫ ⚫ ⚫ ⚫ https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3733

26.

histogram_quantile(0.99, sum(rate(request_duration_seconds_bucket[5m])) by(job, le) ) histogram_quantile(0.99, sum(rate(request_duration_seconds[5m])) by(job) ) ⚫