2023-08-25 21:35:42 +00:00
|
|
|
# Minimal valid case: an empty histogram.
|
|
|
|
load 5m
|
|
|
|
empty_histogram {{}}
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m empty_histogram
|
2023-08-25 21:35:42 +00:00
|
|
|
{__name__="empty_histogram"} {{}}
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_count(empty_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 0
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_sum(empty_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 0
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_avg(empty_histogram)
|
2024-02-01 17:28:42 +00:00
|
|
|
{} NaN
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_fraction(-Inf, +Inf, empty_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} NaN
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_fraction(0, 8, empty_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} NaN
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
2023-08-25 21:35:42 +00:00
|
|
|
|
|
|
|
# buckets:[1 2 1] means 1 observation in the 1st bucket, 2 observations in the 2nd and 1 observation in the 3rd (total 4).
|
|
|
|
load 5m
|
|
|
|
single_histogram {{schema:0 sum:5 count:4 buckets:[1 2 1]}}
|
|
|
|
|
|
|
|
# histogram_count extracts the count property from the histogram.
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_count(single_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 4
|
|
|
|
|
|
|
|
# histogram_sum extracts the sum property from the histogram.
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_sum(single_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 5
|
|
|
|
|
2024-02-01 17:28:42 +00:00
|
|
|
# histogram_avg calculates the average from sum and count properties.
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_avg(single_histogram)
|
2024-02-01 17:28:42 +00:00
|
|
|
{} 1.25
|
|
|
|
|
2023-08-25 21:35:42 +00:00
|
|
|
# We expect half of the values to fall in the range 1 < x <= 2.
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_fraction(1, 2, single_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 0.5
|
|
|
|
|
|
|
|
# We expect all values to fall in the range 0 < x <= 8.
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_fraction(0, 8, single_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 1
|
|
|
|
|
|
|
|
# Median is 1.5 due to linear estimation of the midpoint of the middle bucket, whose values are within range 1 < x <= 2.
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_quantile(0.5, single_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 1.5
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
2023-08-25 21:35:42 +00:00
|
|
|
|
|
|
|
# Repeat the same histogram 10 times.
|
|
|
|
load 5m
|
|
|
|
multi_histogram {{schema:0 sum:5 count:4 buckets:[1 2 1]}}x10
|
|
|
|
|
|
|
|
eval instant at 5m histogram_count(multi_histogram)
|
|
|
|
{} 4
|
|
|
|
|
|
|
|
eval instant at 5m histogram_sum(multi_histogram)
|
|
|
|
{} 5
|
|
|
|
|
2024-02-01 17:28:42 +00:00
|
|
|
eval instant at 5m histogram_avg(multi_histogram)
|
|
|
|
{} 1.25
|
|
|
|
|
2023-08-25 21:35:42 +00:00
|
|
|
eval instant at 5m histogram_fraction(1, 2, multi_histogram)
|
|
|
|
{} 0.5
|
|
|
|
|
|
|
|
eval instant at 5m histogram_quantile(0.5, multi_histogram)
|
|
|
|
{} 1.5
|
|
|
|
|
|
|
|
|
|
|
|
# Each entry should look the same as the first.
|
|
|
|
eval instant at 50m histogram_count(multi_histogram)
|
|
|
|
{} 4
|
|
|
|
|
|
|
|
eval instant at 50m histogram_sum(multi_histogram)
|
|
|
|
{} 5
|
|
|
|
|
2024-02-01 17:28:42 +00:00
|
|
|
eval instant at 50m histogram_avg(multi_histogram)
|
|
|
|
{} 1.25
|
|
|
|
|
2023-08-25 21:35:42 +00:00
|
|
|
eval instant at 50m histogram_fraction(1, 2, multi_histogram)
|
|
|
|
{} 0.5
|
|
|
|
|
|
|
|
eval instant at 50m histogram_quantile(0.5, multi_histogram)
|
|
|
|
{} 1.5
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
2023-08-25 21:35:42 +00:00
|
|
|
|
|
|
|
# Accumulate the histogram addition for 10 iterations, offset is a bucket position where offset:0 is always the bucket
|
|
|
|
# with an upper limit of 1 and offset:1 is the bucket which follows to the right. Negative offsets represent bucket
|
|
|
|
# positions for upper limits <1 (tending toward zero), where offset:-1 is the bucket to the left of offset:0.
|
|
|
|
load 5m
|
|
|
|
incr_histogram {{schema:0 sum:4 count:4 buckets:[1 2 1]}}+{{sum:2 count:1 buckets:[1] offset:1}}x10
|
|
|
|
|
|
|
|
eval instant at 5m histogram_count(incr_histogram)
|
|
|
|
{} 5
|
|
|
|
|
|
|
|
eval instant at 5m histogram_sum(incr_histogram)
|
|
|
|
{} 6
|
|
|
|
|
2024-02-01 17:28:42 +00:00
|
|
|
eval instant at 5m histogram_avg(incr_histogram)
|
|
|
|
{} 1.2
|
|
|
|
|
2023-08-25 21:35:42 +00:00
|
|
|
# We expect 3/5ths of the values to fall in the range 1 < x <= 2.
|
|
|
|
eval instant at 5m histogram_fraction(1, 2, incr_histogram)
|
|
|
|
{} 0.6
|
|
|
|
|
|
|
|
eval instant at 5m histogram_quantile(0.5, incr_histogram)
|
|
|
|
{} 1.5
|
|
|
|
|
|
|
|
|
|
|
|
eval instant at 50m incr_histogram
|
|
|
|
{__name__="incr_histogram"} {{count:14 sum:24 buckets:[1 12 1]}}
|
|
|
|
|
|
|
|
eval instant at 50m histogram_count(incr_histogram)
|
|
|
|
{} 14
|
|
|
|
|
|
|
|
eval instant at 50m histogram_sum(incr_histogram)
|
|
|
|
{} 24
|
|
|
|
|
2024-02-01 17:28:42 +00:00
|
|
|
eval instant at 50m histogram_avg(incr_histogram)
|
|
|
|
{} 1.7142857142857142
|
|
|
|
|
2023-08-25 21:35:42 +00:00
|
|
|
# We expect 12/14ths of the values to fall in the range 1 < x <= 2.
|
|
|
|
eval instant at 50m histogram_fraction(1, 2, incr_histogram)
|
|
|
|
{} 0.8571428571428571
|
|
|
|
|
|
|
|
eval instant at 50m histogram_quantile(0.5, incr_histogram)
|
|
|
|
{} 1.5
|
|
|
|
|
|
|
|
# Per-second average rate of increase should be 1/(5*60) for count and buckets, then 2/(5*60) for sum.
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 50m rate(incr_histogram[10m])
|
|
|
|
{} {{count:0.0033333333333333335 sum:0.006666666666666667 offset:1 buckets:[0.0033333333333333335]}}
|
2023-08-25 21:35:42 +00:00
|
|
|
|
|
|
|
# Calculate the 50th percentile of observations over the last 10m.
|
|
|
|
eval instant at 50m histogram_quantile(0.5, rate(incr_histogram[10m]))
|
|
|
|
{} 1.5
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
2023-08-25 21:35:42 +00:00
|
|
|
|
|
|
|
# Schema represents the histogram resolution, different schema have compatible bucket boundaries, e.g.:
|
|
|
|
# 0: 1 2 4 8 16 32 64 (higher resolution)
|
|
|
|
# -1: 1 4 16 64 (lower resolution)
|
|
|
|
#
|
|
|
|
# Histograms can be merged as long as the histogram to the right is same resolution or higher.
|
|
|
|
load 5m
|
|
|
|
low_res_histogram {{schema:-1 sum:4 count:1 buckets:[1] offset:1}}+{{schema:0 sum:4 count:4 buckets:[2 2] offset:1}}x1
|
|
|
|
|
|
|
|
eval instant at 5m low_res_histogram
|
|
|
|
{__name__="low_res_histogram"} {{schema:-1 count:5 sum:8 offset:1 buckets:[5]}}
|
|
|
|
|
|
|
|
eval instant at 5m histogram_count(low_res_histogram)
|
|
|
|
{} 5
|
|
|
|
|
|
|
|
eval instant at 5m histogram_sum(low_res_histogram)
|
|
|
|
{} 8
|
|
|
|
|
2024-02-01 17:28:42 +00:00
|
|
|
eval instant at 5m histogram_avg(low_res_histogram)
|
|
|
|
{} 1.6
|
|
|
|
|
2023-08-25 21:35:42 +00:00
|
|
|
# We expect all values to fall into the lower-resolution bucket with the range 1 < x <= 4.
|
|
|
|
eval instant at 5m histogram_fraction(1, 4, low_res_histogram)
|
|
|
|
{} 1
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
2023-08-25 21:35:42 +00:00
|
|
|
|
|
|
|
# z_bucket:1 means there is one observation in the zero bucket and z_bucket_w:0.5 means the zero bucket has the range
|
|
|
|
# 0 < x <= 0.5. Sum and count are expected to represent all observations in the histogram, including those in the zero bucket.
|
|
|
|
load 5m
|
|
|
|
single_zero_histogram {{schema:0 z_bucket:1 z_bucket_w:0.5 sum:0.25 count:1}}
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_count(single_zero_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 1
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_sum(single_zero_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 0.25
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_avg(single_zero_histogram)
|
2024-02-01 17:28:42 +00:00
|
|
|
{} 0.25
|
|
|
|
|
2023-08-25 21:35:42 +00:00
|
|
|
# When only the zero bucket is populated, or there are negative buckets, the distribution is assumed to be equally
|
|
|
|
# distributed around zero; i.e. that there are an equal number of positive and negative observations. Therefore the
|
|
|
|
# entire distribution must lie within the full range of the zero bucket, in this case: -0.5 < x <= +0.5.
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_fraction(-0.5, 0.5, single_zero_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 1
|
|
|
|
|
|
|
|
# Half of the observations are estimated to be zero, as this is the midpoint between -0.5 and +0.5.
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_quantile(0.5, single_zero_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 0
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
2023-08-25 21:35:42 +00:00
|
|
|
|
|
|
|
# Let's turn single_histogram upside-down.
|
|
|
|
load 5m
|
|
|
|
negative_histogram {{schema:0 sum:-5 count:4 n_buckets:[1 2 1]}}
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_count(negative_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 4
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_sum(negative_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} -5
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_avg(negative_histogram)
|
2024-02-01 17:28:42 +00:00
|
|
|
{} -1.25
|
|
|
|
|
2023-08-25 21:35:42 +00:00
|
|
|
# We expect half of the values to fall in the range -2 < x <= -1.
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_fraction(-2, -1, negative_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 0.5
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 1m histogram_quantile(0.5, negative_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} -1.5
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
2023-08-25 21:35:42 +00:00
|
|
|
|
|
|
|
# Two histogram samples.
|
|
|
|
load 5m
|
|
|
|
two_samples_histogram {{schema:0 sum:4 count:4 buckets:[1 2 1]}} {{schema:0 sum:-4 count:4 n_buckets:[1 2 1]}}
|
|
|
|
|
|
|
|
# We expect to see the newest sample.
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 5m histogram_count(two_samples_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 4
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 5m histogram_sum(two_samples_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} -4
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 5m histogram_avg(two_samples_histogram)
|
2024-02-01 17:28:42 +00:00
|
|
|
{} -1
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 5m histogram_fraction(-2, -1, two_samples_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} 0.5
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
eval instant at 5m histogram_quantile(0.5, two_samples_histogram)
|
2023-08-25 21:35:42 +00:00
|
|
|
{} -1.5
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
2023-08-25 21:35:42 +00:00
|
|
|
|
|
|
|
# Add two histograms with negated data.
|
|
|
|
load 5m
|
|
|
|
balanced_histogram {{schema:0 sum:4 count:4 buckets:[1 2 1]}}+{{schema:0 sum:-4 count:4 n_buckets:[1 2 1]}}x1
|
|
|
|
|
|
|
|
eval instant at 5m histogram_count(balanced_histogram)
|
|
|
|
{} 8
|
|
|
|
|
|
|
|
eval instant at 5m histogram_sum(balanced_histogram)
|
|
|
|
{} 0
|
|
|
|
|
2024-02-01 17:28:42 +00:00
|
|
|
eval instant at 5m histogram_avg(balanced_histogram)
|
|
|
|
{} 0
|
|
|
|
|
2023-08-25 21:35:42 +00:00
|
|
|
eval instant at 5m histogram_fraction(0, 4, balanced_histogram)
|
|
|
|
{} 0.5
|
|
|
|
|
|
|
|
# If the quantile happens to be located in a span of empty buckets, the actually returned value is the lower bound of
|
|
|
|
# the first populated bucket after the span of empty buckets.
|
|
|
|
eval instant at 5m histogram_quantile(0.5, balanced_histogram)
|
|
|
|
{} 0.5
|
2024-01-26 09:04:02 +00:00
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-01-26 09:04:02 +00:00
|
|
|
# Add histogram to test sum(last_over_time) regression
|
|
|
|
load 5m
|
|
|
|
incr_sum_histogram{number="1"} {{schema:0 sum:0 count:0 buckets:[1]}}+{{schema:0 sum:1 count:1 buckets:[1]}}x10
|
|
|
|
incr_sum_histogram{number="2"} {{schema:0 sum:0 count:0 buckets:[1]}}+{{schema:0 sum:2 count:1 buckets:[1]}}x10
|
|
|
|
|
|
|
|
eval instant at 50m histogram_sum(sum(incr_sum_histogram))
|
|
|
|
{} 30
|
|
|
|
|
|
|
|
eval instant at 50m histogram_sum(sum(last_over_time(incr_sum_histogram[5m])))
|
|
|
|
{} 30
|
2024-02-25 19:46:26 +00:00
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-10 20:17:09 +00:00
|
|
|
# Apply rate function to histogram.
|
2024-03-21 21:47:47 +00:00
|
|
|
load 15s
|
2024-04-10 20:17:09 +00:00
|
|
|
histogram_rate {{schema:1 count:12 sum:18.4 z_bucket:2 z_bucket_w:0.001 buckets:[1 2 0 1 1] n_buckets:[1 2 0 1 1]}}+{{schema:1 count:9 sum:18.4 z_bucket:1 z_bucket_w:0.001 buckets:[1 1 0 1 1] n_buckets:[1 1 0 1 1]}}x100
|
2024-02-25 19:46:26 +00:00
|
|
|
|
2024-04-10 20:17:09 +00:00
|
|
|
eval instant at 5m rate(histogram_rate[45s])
|
|
|
|
{} {{schema:1 count:0.6 sum:1.2266666666666652 z_bucket:0.06666666666666667 z_bucket_w:0.001 buckets:[0.06666666666666667 0.06666666666666667 0 0.06666666666666667 0.06666666666666667] n_buckets:[0.06666666666666667 0.06666666666666667 0 0.06666666666666667 0.06666666666666667]}}
|
|
|
|
|
|
|
|
eval range from 5m to 5m30s step 30s rate(histogram_rate[45s])
|
|
|
|
{} {{schema:1 count:0.6 sum:1.2266666666666652 z_bucket:0.06666666666666667 z_bucket_w:0.001 buckets:[0.06666666666666667 0.06666666666666667 0 0.06666666666666667 0.06666666666666667] n_buckets:[0.06666666666666667 0.06666666666666667 0 0.06666666666666667 0.06666666666666667]}}x1
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-11 12:43:49 +00:00
|
|
|
# Apply count and sum function to histogram.
|
2024-04-10 20:17:09 +00:00
|
|
|
load 10m
|
|
|
|
histogram_count_sum_2 {{schema:0 count:24 sum:100 z_bucket:4 z_bucket_w:0.001 buckets:[2 3 0 1 4] n_buckets:[2 3 0 1 4]}}x1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_count(histogram_count_sum_2)
|
|
|
|
{} 24
|
|
|
|
|
|
|
|
eval instant at 10m histogram_sum(histogram_count_sum_2)
|
|
|
|
{} 100
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-10 20:17:09 +00:00
|
|
|
# Apply stddev and stdvar function to histogram with {1, 2, 3, 4} (low res).
|
|
|
|
load 10m
|
|
|
|
histogram_stddev_stdvar_1 {{schema:2 count:4 sum:10 buckets:[1 0 0 0 1 0 0 1 1]}}x1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stddev(histogram_stddev_stdvar_1)
|
|
|
|
{} 1.0787993180043811
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stdvar(histogram_stddev_stdvar_1)
|
|
|
|
{} 1.163807968526718
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-10 20:17:09 +00:00
|
|
|
# Apply stddev and stdvar function to histogram with {1, 1, 1, 1} (high res).
|
|
|
|
load 10m
|
|
|
|
histogram_stddev_stdvar_2 {{schema:8 count:10 sum:10 buckets:[1 2 3 4]}}x1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stddev(histogram_stddev_stdvar_2)
|
|
|
|
{} 0.0048960313898237465
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stdvar(histogram_stddev_stdvar_2)
|
|
|
|
{} 2.3971123370139447e-05
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-10 20:17:09 +00:00
|
|
|
# Apply stddev and stdvar function to histogram with {-50, -8, 0, 3, 8, 9}.
|
|
|
|
load 10m
|
|
|
|
histogram_stddev_stdvar_3 {{schema:3 count:7 sum:62 z_bucket:1 buckets:[0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ] n_buckets:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ]}}x1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stddev(histogram_stddev_stdvar_3)
|
|
|
|
{} 42.947236400258
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stdvar(histogram_stddev_stdvar_3)
|
|
|
|
{} 1844.4651144196398
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-10 20:17:09 +00:00
|
|
|
# Apply stddev and stdvar function to histogram with {-100000, -10000, -1000, -888, -888, -100, -50, -9, -8, -3}.
|
|
|
|
load 10m
|
|
|
|
histogram_stddev_stdvar_4 {{schema:0 count:10 sum:-112946 z_bucket:0 n_buckets:[0 0 1 1 1 0 1 1 0 0 3 0 0 0 1 0 0 1]}}x1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stddev(histogram_stddev_stdvar_4)
|
|
|
|
{} 27556.344499842
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stdvar(histogram_stddev_stdvar_4)
|
|
|
|
{} 759352122.1939945
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-10 20:17:09 +00:00
|
|
|
# Apply stddev and stdvar function to histogram with {-10x10}.
|
|
|
|
load 10m
|
|
|
|
histogram_stddev_stdvar_5 {{schema:0 count:10 sum:-100 z_bucket:0 n_buckets:[0 0 0 0 10]}}x1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stddev(histogram_stddev_stdvar_5)
|
|
|
|
{} 1.3137084989848
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stdvar(histogram_stddev_stdvar_5)
|
|
|
|
{} 1.725830020304794
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-10 20:17:09 +00:00
|
|
|
# Apply stddev and stdvar function to histogram with {-50, -8, 0, 3, 8, 9, NaN}.
|
|
|
|
load 10m
|
|
|
|
histogram_stddev_stdvar_6 {{schema:3 count:7 sum:NaN z_bucket:1 buckets:[0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ] n_buckets:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ]}}x1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stddev(histogram_stddev_stdvar_6)
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stdvar(histogram_stddev_stdvar_6)
|
|
|
|
{} NaN
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-10 20:17:09 +00:00
|
|
|
# Apply stddev and stdvar function to histogram with {-50, -8, 0, 3, 8, 9, Inf}.
|
|
|
|
load 10m
|
|
|
|
histogram_stddev_stdvar_7 {{schema:3 count:7 sum:Inf z_bucket:1 buckets:[0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ] n_buckets:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ]}}x1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_stddev(histogram_stddev_stdvar_7)
|
2024-06-28 01:19:27 +00:00
|
|
|
{} Inf
|
2024-04-10 20:17:09 +00:00
|
|
|
|
|
|
|
eval instant at 10m histogram_stdvar(histogram_stddev_stdvar_7)
|
2024-06-28 01:19:27 +00:00
|
|
|
{} Inf
|
2024-04-10 20:17:09 +00:00
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-11 12:43:49 +00:00
|
|
|
# Apply quantile function to histogram with all positive buckets with zero bucket.
|
2024-04-10 20:17:09 +00:00
|
|
|
load 10m
|
|
|
|
histogram_quantile_1 {{schema:0 count:12 sum:100 z_bucket:2 z_bucket_w:0.001 buckets:[2 3 0 1 4]}}x1
|
|
|
|
|
2024-06-07 11:17:14 +00:00
|
|
|
eval_warn instant at 10m histogram_quantile(1.001, histogram_quantile_1)
|
2024-04-10 20:17:09 +00:00
|
|
|
{} Inf
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(1, histogram_quantile_1)
|
|
|
|
{} 16
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.99, histogram_quantile_1)
|
|
|
|
{} 15.759999999999998
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.9, histogram_quantile_1)
|
|
|
|
{} 13.600000000000001
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.6, histogram_quantile_1)
|
|
|
|
{} 4.799999999999997
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.5, histogram_quantile_1)
|
|
|
|
{} 1.6666666666666665
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.1, histogram_quantile_1)
|
|
|
|
{} 0.0006000000000000001
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0, histogram_quantile_1)
|
|
|
|
{} 0
|
|
|
|
|
2024-06-07 11:17:14 +00:00
|
|
|
eval_warn instant at 10m histogram_quantile(-1, histogram_quantile_1)
|
2024-04-10 20:17:09 +00:00
|
|
|
{} -Inf
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-11 12:43:49 +00:00
|
|
|
# Apply quantile function to histogram with all negative buckets with zero bucket.
|
2024-04-10 20:17:09 +00:00
|
|
|
load 10m
|
|
|
|
histogram_quantile_2 {{schema:0 count:12 sum:100 z_bucket:2 z_bucket_w:0.001 n_buckets:[2 3 0 1 4]}}x1
|
|
|
|
|
2024-06-07 11:17:14 +00:00
|
|
|
eval_warn instant at 10m histogram_quantile(1.001, histogram_quantile_2)
|
2024-04-10 20:17:09 +00:00
|
|
|
{} Inf
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(1, histogram_quantile_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.99, histogram_quantile_2)
|
|
|
|
{} -6.000000000000048e-05
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.9, histogram_quantile_2)
|
|
|
|
{} -0.0005999999999999996
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.5, histogram_quantile_2)
|
|
|
|
{} -1.6666666666666667
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.1, histogram_quantile_2)
|
|
|
|
{} -13.6
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0, histogram_quantile_2)
|
|
|
|
{} -16
|
|
|
|
|
2024-06-07 11:17:14 +00:00
|
|
|
eval_warn instant at 10m histogram_quantile(-1, histogram_quantile_2)
|
2024-04-10 20:17:09 +00:00
|
|
|
{} -Inf
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-11 12:43:49 +00:00
|
|
|
# Apply quantile function to histogram with both positive and negative buckets with zero bucket.
|
2024-04-10 20:17:09 +00:00
|
|
|
load 10m
|
|
|
|
histogram_quantile_3 {{schema:0 count:24 sum:100 z_bucket:4 z_bucket_w:0.001 buckets:[2 3 0 1 4] n_buckets:[2 3 0 1 4]}}x1
|
|
|
|
|
2024-06-07 11:17:14 +00:00
|
|
|
eval_warn instant at 10m histogram_quantile(1.001, histogram_quantile_3)
|
2024-04-10 20:17:09 +00:00
|
|
|
{} Inf
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(1, histogram_quantile_3)
|
|
|
|
{} 16
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.99, histogram_quantile_3)
|
|
|
|
{} 15.519999999999996
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.9, histogram_quantile_3)
|
|
|
|
{} 11.200000000000003
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.7, histogram_quantile_3)
|
|
|
|
{} 1.2666666666666657
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.55, histogram_quantile_3)
|
|
|
|
{} 0.0006000000000000005
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.5, histogram_quantile_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.45, histogram_quantile_3)
|
|
|
|
{} -0.0005999999999999996
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.3, histogram_quantile_3)
|
|
|
|
{} -1.266666666666667
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.1, histogram_quantile_3)
|
|
|
|
{} -11.2
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0.01, histogram_quantile_3)
|
|
|
|
{} -15.52
|
|
|
|
|
|
|
|
eval instant at 10m histogram_quantile(0, histogram_quantile_3)
|
|
|
|
{} -16
|
|
|
|
|
2024-06-07 11:17:14 +00:00
|
|
|
eval_warn instant at 10m histogram_quantile(-1, histogram_quantile_3)
|
2024-04-10 20:17:09 +00:00
|
|
|
{} -Inf
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-10 20:17:09 +00:00
|
|
|
# Apply fraction function to empty histogram.
|
|
|
|
load 10m
|
|
|
|
histogram_fraction_1 {{}}x1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(3.1415, 42, histogram_fraction_1)
|
|
|
|
{} NaN
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-10 20:17:09 +00:00
|
|
|
# Apply fraction function to histogram with positive and zero buckets.
|
|
|
|
load 10m
|
|
|
|
histogram_fraction_2 {{schema:0 count:12 sum:100 z_bucket:2 z_bucket_w:0.001 buckets:[2 3 0 1 4]}}x1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0, +Inf, histogram_fraction_2)
|
|
|
|
{} 1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-Inf, 0, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-0.001, 0, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0, 0.001, histogram_fraction_2)
|
|
|
|
{} 0.16666666666666666
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0, 0.0005, histogram_fraction_2)
|
|
|
|
{} 0.08333333333333333
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0.001, inf, histogram_fraction_2)
|
|
|
|
{} 0.8333333333333334
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-inf, -0.001, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1, 2, histogram_fraction_2)
|
|
|
|
{} 0.25
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1.5, 2, histogram_fraction_2)
|
|
|
|
{} 0.125
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1, 8, histogram_fraction_2)
|
|
|
|
{} 0.3333333333333333
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1, 6, histogram_fraction_2)
|
|
|
|
{} 0.2916666666666667
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1.5, 6, histogram_fraction_2)
|
|
|
|
{} 0.16666666666666666
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-2, -1, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-2, -1.5, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-8, -1, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-6, -1, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-6, -1.5, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(42, 3.1415, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0, 0, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0.000001, 0.000001, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(42, 42, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-3.1, -3.1, histogram_fraction_2)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(3.1415, NaN, histogram_fraction_2)
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(NaN, 42, histogram_fraction_2)
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(NaN, NaN, histogram_fraction_2)
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-Inf, +Inf, histogram_fraction_2)
|
|
|
|
{} 1
|
|
|
|
|
|
|
|
# Apply fraction function to histogram with negative and zero buckets.
|
|
|
|
load 10m
|
|
|
|
histogram_fraction_3 {{schema:0 count:12 sum:100 z_bucket:2 z_bucket_w:0.001 n_buckets:[2 3 0 1 4]}}x1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0, +Inf, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-Inf, 0, histogram_fraction_3)
|
|
|
|
{} 1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-0.001, 0, histogram_fraction_3)
|
|
|
|
{} 0.16666666666666666
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0, 0.001, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-0.0005, 0, histogram_fraction_3)
|
|
|
|
{} 0.08333333333333333
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0.001, inf, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-inf, -0.001, histogram_fraction_3)
|
|
|
|
{} 0.8333333333333334
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1, 2, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1.5, 2, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1, 8, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1, 6, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1.5, 6, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-2, -1, histogram_fraction_3)
|
|
|
|
{} 0.25
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-2, -1.5, histogram_fraction_3)
|
|
|
|
{} 0.125
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-8, -1, histogram_fraction_3)
|
|
|
|
{} 0.3333333333333333
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-6, -1, histogram_fraction_3)
|
|
|
|
{} 0.2916666666666667
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-6, -1.5, histogram_fraction_3)
|
|
|
|
{} 0.16666666666666666
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(42, 3.1415, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0, 0, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0.000001, 0.000001, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(42, 42, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-3.1, -3.1, histogram_fraction_3)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(3.1415, NaN, histogram_fraction_3)
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(NaN, 42, histogram_fraction_3)
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(NaN, NaN, histogram_fraction_3)
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-Inf, +Inf, histogram_fraction_3)
|
|
|
|
{} 1
|
|
|
|
|
2024-04-08 16:46:52 +00:00
|
|
|
clear
|
|
|
|
|
2024-04-10 20:17:09 +00:00
|
|
|
# Apply fraction function to histogram with both positive, negative and zero buckets.
|
|
|
|
load 10m
|
|
|
|
histogram_fraction_4 {{schema:0 count:24 sum:100 z_bucket:4 z_bucket_w:0.001 buckets:[2 3 0 1 4] n_buckets:[2 3 0 1 4]}}x1
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0, +Inf, histogram_fraction_4)
|
|
|
|
{} 0.5
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-Inf, 0, histogram_fraction_4)
|
|
|
|
{} 0.5
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-0.001, 0, histogram_fraction_4)
|
|
|
|
{} 0.08333333333333333
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0, 0.001, histogram_fraction_4)
|
|
|
|
{} 0.08333333333333333
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-0.0005, 0.0005, histogram_fraction_4)
|
|
|
|
{} 0.08333333333333333
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0.001, inf, histogram_fraction_4)
|
|
|
|
{} 0.4166666666666667
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-inf, -0.001, histogram_fraction_4)
|
|
|
|
{} 0.4166666666666667
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1, 2, histogram_fraction_4)
|
|
|
|
{} 0.125
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1.5, 2, histogram_fraction_4)
|
|
|
|
{} 0.0625
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1, 8, histogram_fraction_4)
|
|
|
|
{} 0.16666666666666666
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1, 6, histogram_fraction_4)
|
|
|
|
{} 0.14583333333333334
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(1.5, 6, histogram_fraction_4)
|
|
|
|
{} 0.08333333333333333
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-2, -1, histogram_fraction_4)
|
|
|
|
{} 0.125
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-2, -1.5, histogram_fraction_4)
|
|
|
|
{} 0.0625
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-8, -1, histogram_fraction_4)
|
|
|
|
{} 0.16666666666666666
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-6, -1, histogram_fraction_4)
|
|
|
|
{} 0.14583333333333334
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-6, -1.5, histogram_fraction_4)
|
|
|
|
{} 0.08333333333333333
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(42, 3.1415, histogram_fraction_4)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0, 0, histogram_fraction_4)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(0.000001, 0.000001, histogram_fraction_4)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(42, 42, histogram_fraction_4)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-3.1, -3.1, histogram_fraction_4)
|
|
|
|
{} 0
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(3.1415, NaN, histogram_fraction_4)
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(NaN, 42, histogram_fraction_4)
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(NaN, NaN, histogram_fraction_4)
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
eval instant at 10m histogram_fraction(-Inf, +Inf, histogram_fraction_4)
|
2024-05-06 18:53:47 +00:00
|
|
|
{} 1
|
2024-06-06 15:47:38 +00:00
|
|
|
|
2024-07-10 09:55:26 +00:00
|
|
|
eval instant at 10m histogram_sum(scalar(histogram_fraction(-Inf, +Inf, sum(histogram_fraction_4))) * histogram_fraction_4)
|
|
|
|
{} 100
|
|
|
|
|
2024-06-06 15:47:38 +00:00
|
|
|
clear
|
|
|
|
|
|
|
|
# Counter reset only noticeable in a single bucket.
|
|
|
|
load 5m
|
|
|
|
reset_in_bucket {{schema:0 count:4 sum:5 buckets:[1 2 1]}} {{schema:0 count:5 sum:6 buckets:[1 1 3]}} {{schema:0 count:6 sum:7 buckets:[1 2 3]}}
|
|
|
|
|
|
|
|
eval instant at 10m increase(reset_in_bucket[15m])
|
|
|
|
{} {{count:9 sum:10.5 buckets:[1.5 3 4.5]}}
|
|
|
|
|
|
|
|
# The following two test the "fast path" where only sum and count is decoded.
|
|
|
|
eval instant at 10m histogram_count(increase(reset_in_bucket[15m]))
|
|
|
|
{} 9
|
|
|
|
|
|
|
|
eval instant at 10m histogram_sum(increase(reset_in_bucket[15m]))
|
|
|
|
{} 10.5
|
|
|
|
|
2024-06-20 14:50:00 +00:00
|
|
|
clear
|
|
|
|
|
2024-05-08 11:58:24 +00:00
|
|
|
# Test native histograms with custom buckets.
|
|
|
|
load 5m
|
2024-06-07 11:17:14 +00:00
|
|
|
custom_buckets_histogram {{schema:-53 sum:5 count:4 custom_values:[5 10] buckets:[1 2 1]}}x10
|
2024-05-08 11:58:24 +00:00
|
|
|
|
|
|
|
eval instant at 5m histogram_fraction(5, 10, custom_buckets_histogram)
|
2024-06-07 11:17:14 +00:00
|
|
|
{} 0.5
|
2024-05-08 11:58:24 +00:00
|
|
|
|
|
|
|
eval instant at 5m histogram_quantile(0.5, custom_buckets_histogram)
|
2024-06-07 11:17:14 +00:00
|
|
|
{} 7.5
|
2024-05-08 11:58:24 +00:00
|
|
|
|
|
|
|
eval instant at 5m sum(custom_buckets_histogram)
|
2024-06-07 11:17:14 +00:00
|
|
|
{} {{schema:-53 sum:5 count:4 custom_values:[5 10] buckets:[1 2 1]}}
|
2024-08-06 08:10:40 +00:00
|
|
|
|
|
|
|
clear
|
|
|
|
|
|
|
|
# Test 'this native histogram metric is not a gauge' warning for rate
|
|
|
|
load 30s
|
|
|
|
some_metric {{schema:0 sum:1 count:1 buckets:[1] counter_reset_hint:gauge}} {{schema:0 sum:2 count:2 buckets:[2] counter_reset_hint:gauge}} {{schema:0 sum:3 count:3 buckets:[3] counter_reset_hint:gauge}}
|
|
|
|
|
|
|
|
# Test the case where we only have two points for rate
|
|
|
|
eval_warn instant at 30s rate(some_metric[30s])
|
|
|
|
{} {{count:0.03333333333333333 sum:0.03333333333333333 buckets:[0.03333333333333333]}}
|
|
|
|
|
|
|
|
# Test the case where we have more than two points for rate
|
|
|
|
eval_warn instant at 1m rate(some_metric[1m])
|
|
|
|
{} {{count:0.03333333333333333 sum:0.03333333333333333 buckets:[0.03333333333333333]}}
|
2024-08-07 05:30:01 +00:00
|
|
|
|
2024-08-07 04:39:50 +00:00
|
|
|
clear
|
|
|
|
|
|
|
|
# Test rate() over mixed exponential and custom buckets.
|
|
|
|
load 30s
|
|
|
|
some_metric {{schema:0 sum:1 count:1 buckets:[1]}} {{schema:-53 sum:1 count:1 custom_values:[5 10] buckets:[1]}} {{schema:0 sum:5 count:4 buckets:[1 2 1]}} {{schema:-53 sum:1 count:1 custom_values:[5 10] buckets:[1]}}
|
|
|
|
|
|
|
|
# Start and end with exponential, with custom in the middle.
|
|
|
|
eval_warn instant at 1m rate(some_metric[1m])
|
|
|
|
# Should produce no results.
|
|
|
|
|
|
|
|
# Start and end with custom, with exponential in the middle.
|
|
|
|
eval_warn instant at 1m30s rate(some_metric[1m])
|
|
|
|
# Should produce no results.
|
|
|
|
|
|
|
|
# Start with custom, end with exponential.
|
|
|
|
eval_warn instant at 1m rate(some_metric[30s])
|
|
|
|
# Should produce no results.
|
|
|
|
|
|
|
|
# Start with exponential, end with custom.
|
|
|
|
eval_warn instant at 30s rate(some_metric[30s])
|
|
|
|
# Should produce no results.
|
2024-08-09 03:58:54 +00:00
|
|
|
|
|
|
|
clear
|
|
|
|
|
2024-08-12 08:39:08 +00:00
|
|
|
# Histogram with constant buckets.
|
|
|
|
load 1m
|
|
|
|
const_histogram {{schema:0 sum:1 count:1 buckets:[1 1 1]}} {{schema:0 sum:1 count:1 buckets:[1 1 1]}} {{schema:0 sum:1 count:1 buckets:[1 1 1]}} {{schema:0 sum:1 count:1 buckets:[1 1 1]}} {{schema:0 sum:1 count:1 buckets:[1 1 1]}}
|
|
|
|
|
|
|
|
# There is no change to the bucket count over time, thus rate is 0 in each bucket.
|
|
|
|
# However native histograms do not represent empty buckets, so here the zeros are implicit.
|
|
|
|
eval instant at 5m rate(const_histogram[5m])
|
|
|
|
{} {{schema:0 sum:0 count:0}}
|
|
|
|
|
2024-08-13 13:26:07 +00:00
|
|
|
# Zero buckets mean no observations, thus the denominator in the average is 0
|
|
|
|
# leading to 0/0, which is NaN.
|
2024-08-12 08:39:08 +00:00
|
|
|
eval instant at 5m histogram_avg(rate(const_histogram[5m]))
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
# Zero buckets mean no observations, so count is 0.
|
|
|
|
eval instant at 5m histogram_count(rate(const_histogram[5m]))
|
|
|
|
{} 0.0
|
|
|
|
|
2024-08-13 13:26:07 +00:00
|
|
|
# Zero buckets mean no observations and empty histogram has a sum of 0 by definition.
|
2024-08-12 08:39:08 +00:00
|
|
|
eval instant at 5m histogram_sum(rate(const_histogram[5m]))
|
|
|
|
{} 0.0
|
|
|
|
|
2024-08-13 13:26:07 +00:00
|
|
|
# Zero buckets mean no observations, thus the denominator in the fraction is 0,
|
|
|
|
# leading to 0/0, which is NaN.
|
2024-08-12 08:39:08 +00:00
|
|
|
eval instant at 5m histogram_fraction(0.0, 1.0, rate(const_histogram[5m]))
|
|
|
|
{} NaN
|
|
|
|
|
2024-08-13 13:26:07 +00:00
|
|
|
# Workaround to calculate the observation count corresponding to NaN fraction.
|
|
|
|
eval instant at 5m histogram_count(rate(const_histogram[5m])) == 0.0 or histogram_fraction(0.0, 1.0, rate(const_histogram[5m])) * histogram_count(rate(const_histogram[5m]))
|
|
|
|
{} 0.0
|
|
|
|
|
2024-08-12 10:04:45 +00:00
|
|
|
# Zero buckets mean no observations, so there is no value that observations fall below,
|
2024-08-12 08:39:08 +00:00
|
|
|
# which means that any quantile is a NaN.
|
|
|
|
eval instant at 5m histogram_quantile(1.0, rate(const_histogram[5m]))
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
# Zero buckets mean no observations, so there is no standard deviation.
|
|
|
|
eval instant at 5m histogram_stddev(rate(const_histogram[5m]))
|
|
|
|
{} NaN
|
|
|
|
|
|
|
|
# Zero buckets mean no observations, so there is no standard variance.
|
|
|
|
eval instant at 5m histogram_stdvar(rate(const_histogram[5m]))
|
|
|
|
{} NaN
|
2024-08-13 21:52:08 +00:00
|
|
|
|
|
|
|
clear
|
|
|
|
|
2024-08-07 05:30:01 +00:00
|
|
|
# Test mixing exponential and custom buckets.
|
|
|
|
load 6m
|
|
|
|
metric{series="exponential"} {{sum:4 count:3 buckets:[1 2 1]}} _ {{sum:4 count:3 buckets:[1 2 1]}}
|
|
|
|
metric{series="other-exponential"} {{sum:3 count:2 buckets:[1 1 1]}} _ {{sum:3 count:2 buckets:[1 1 1]}}
|
|
|
|
metric{series="custom"} _ {{schema:-53 sum:1 count:1 custom_values:[5 10] buckets:[1]}} {{schema:-53 sum:1 count:1 custom_values:[5 10] buckets:[1]}}
|
|
|
|
metric{series="other-custom"} _ {{schema:-53 sum:15 count:2 custom_values:[5 10] buckets:[0 2]}} {{schema:-53 sum:15 count:2 custom_values:[5 10] buckets:[0 2]}}
|
|
|
|
|
|
|
|
# T=0: only exponential
|
|
|
|
# T=6: only custom
|
2024-08-09 03:51:31 +00:00
|
|
|
# T=12: mixed, should be ignored and emit a warning
|
2024-08-07 05:30:01 +00:00
|
|
|
eval_warn range from 0 to 12m step 6m sum(metric)
|
|
|
|
{} {{sum:7 count:5 buckets:[2 3 2]}} {{schema:-53 sum:16 count:3 custom_values:[5 10] buckets:[1 2]}} _
|
|
|
|
|
2024-08-07 05:32:35 +00:00
|
|
|
eval_warn range from 0 to 12m step 6m avg(metric)
|
|
|
|
{} {{sum:3.5 count:2.5 buckets:[1 1.5 1]}} {{schema:-53 sum:8 count:1.5 custom_values:[5 10] buckets:[0.5 1]}} _
|
|
|
|
|
2024-08-07 05:30:01 +00:00
|
|
|
clear
|
|
|
|
|
|
|
|
# Test incompatible custom bucket schemas.
|
|
|
|
load 6m
|
|
|
|
metric{series="1"} _ {{schema:-53 sum:1 count:1 custom_values:[5 10] buckets:[1]}} {{schema:-53 sum:1 count:1 custom_values:[5 10] buckets:[1]}}
|
|
|
|
metric{series="2"} {{schema:-53 sum:1 count:1 custom_values:[2] buckets:[1]}} _ {{schema:-53 sum:1 count:1 custom_values:[2] buckets:[1]}}
|
|
|
|
metric{series="3"} {{schema:-53 sum:1 count:1 custom_values:[5 10] buckets:[1]}} {{schema:-53 sum:1 count:1 custom_values:[5 10] buckets:[1]}} {{schema:-53 sum:1 count:1 custom_values:[5 10] buckets:[1]}}
|
|
|
|
|
|
|
|
# T=0: incompatible, should be ignored and emit a warning
|
|
|
|
# T=6: compatible
|
|
|
|
# T=12: incompatible followed by compatible, should be ignored and emit a warning
|
|
|
|
eval_warn range from 0 to 12m step 6m sum(metric)
|
|
|
|
{} _ {{schema:-53 sum:2 count:2 custom_values:[5 10] buckets:[2]}} _
|
2024-08-07 05:32:35 +00:00
|
|
|
|
|
|
|
eval_warn range from 0 to 12m step 6m avg(metric)
|
|
|
|
{} _ {{schema:-53 sum:1 count:1 custom_values:[5 10] buckets:[1]}} _
|
2024-08-09 03:57:37 +00:00
|
|
|
|
|
|
|
clear
|
|
|
|
|
|
|
|
load 1m
|
|
|
|
metric{group="just-floats", series="1"} 2
|
|
|
|
metric{group="just-floats", series="2"} 3
|
|
|
|
metric{group="just-exponential-histograms", series="1"} {{sum:3 count:4 buckets:[1 2 1]}}
|
|
|
|
metric{group="just-exponential-histograms", series="2"} {{sum:2 count:3 buckets:[1 1 1]}}
|
|
|
|
metric{group="just-custom-histograms", series="1"} {{schema:-53 sum:1 count:1 custom_values:[2] buckets:[1]}}
|
|
|
|
metric{group="just-custom-histograms", series="2"} {{schema:-53 sum:3 count:4 custom_values:[2] buckets:[7]}}
|
|
|
|
metric{group="floats-and-histograms", series="1"} 2
|
|
|
|
metric{group="floats-and-histograms", series="2"} {{sum:2 count:3 buckets:[1 1 1]}}
|
|
|
|
metric{group="exponential-and-custom-histograms", series="1"} {{sum:2 count:3 buckets:[1 1 1]}}
|
|
|
|
metric{group="exponential-and-custom-histograms", series="2"} {{schema:-53 sum:1 count:1 custom_values:[5 10] buckets:[1]}}
|
|
|
|
metric{group="incompatible-custom-histograms", series="1"} {{schema:-53 sum:1 count:1 custom_values:[5 10] buckets:[1]}}
|
|
|
|
metric{group="incompatible-custom-histograms", series="2"} {{schema:-53 sum:1 count:1 custom_values:[2] buckets:[1]}}
|
|
|
|
|
|
|
|
eval_warn instant at 0 sum by (group) (metric)
|
|
|
|
{group="just-floats"} 5
|
|
|
|
{group="just-exponential-histograms"} {{sum:5 count:7 buckets:[2 3 2]}}
|
|
|
|
{group="just-custom-histograms"} {{schema:-53 sum:4 count:5 custom_values:[2] buckets:[8]}}
|