Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions promql/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ func extendedRate(vals Matrix, args parser.Expressions, enh *EvalNodeHelper, isC
if f[lastSampleIndex].T <= rangeStart {
return enh.Out, annos
}
if smoothed && f[firstSampleIndex].T > rangeEnd {
return enh.Out, annos
}

left := pickOrInterpolateLeft(f, firstSampleIndex, rangeStart, smoothed, isCounter)
right := pickOrInterpolateRight(f, lastSampleIndex, rangeEnd, smoothed, isCounter)
Expand Down
18 changes: 17 additions & 1 deletion promql/promqltest/testdata/extended_vectors.test
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,20 @@ eval instant at 45s withreset smoothed
withreset 3

eval instant at 30s notregular smoothed
notregular 2
notregular 2

# Smoothed rate returns empty when data is only before or only after the range.
clear
load 10s
metric _ 5+1x4

eval instant at 5s rate(metric[5s] smoothed)

eval instant at 5s increase(metric[5s] smoothed)

eval instant at 15s increase(metric[10s] smoothed)
{} 0.5

eval instant at 60s rate(metric[5s] smoothed)

eval instant at 60s increase(metric[5s] smoothed)
Loading