PromQL: Fix native histogram last_over_time with offset

Signed-off-by: 🌲 Harry 🌊 John 🏔 <johrry@amazon.com>
pull/16744/head
🌲 Harry 🌊 John 🏔 1 week ago
parent cfa922e677
commit 59bf3d442b
  1. 2
      promql/functions.go
  2. 9
      promql/promqltest/testdata/native_histograms.test

@ -747,7 +747,7 @@ func funcLastOverTime(vals []parser.Value, _ parser.Expressions, enh *EvalNodeHe
h = el.Histograms[len(el.Histograms)-1] h = el.Histograms[len(el.Histograms)-1]
} }
if h.H == nil || h.T < f.T { if h.H == nil || (len(el.Floats) > 0 && h.T < f.T) {
return append(enh.Out, Sample{ return append(enh.Out, Sample{
Metric: el.Metric, Metric: el.Metric,
F: f.F, F: f.F,

@ -1319,3 +1319,12 @@ eval instant at 10m histogram_sub_3{idx="0"} - ignoring(idx) histogram_sub_3{idx
{} {{schema:0 count:-30 sum:-1111.1 z_bucket:-2 z_bucket_w:0.001 buckets:[-1 0 -1 -2 -1 -1 -1] n_buckets:[0 2 -2 -2 -7 0 0 0 0 -5 -5 -2]}} {} {{schema:0 count:-30 sum:-1111.1 z_bucket:-2 z_bucket_w:0.001 buckets:[-1 0 -1 -2 -1 -1 -1] n_buckets:[0 2 -2 -2 -7 0 0 0 0 -5 -5 -2]}}
clear clear
# Test native histograms with last_over_time subquery
load 2m
http_request_duration_seconds{pod="nginx-1"} {{schema:0 count:3 sum:14.00 buckets:[1 2]}}x20
eval range from 0s to 60s step 15s last_over_time({__name__="http_request_duration_seconds"} @ start()[1h:1m] offset 1m16s)
{__name__="http_request_duration_seconds", pod="nginx-1"} {{count:3 sum:14 buckets:[1 2]}}x4
clear

Loading…
Cancel
Save