mirror of
https://github.com/prometheus/prometheus.git
synced 2025-09-21 13:51:00 +02:00
fix NH load expression with incrementation more than once
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
This commit is contained in:
parent
a2f54d6066
commit
f83e964231
@ -512,7 +512,7 @@ func lexHistogram(l *Lexer) stateFn {
|
|||||||
l.histogramState = histogramStateNone
|
l.histogramState = histogramStateNone
|
||||||
l.next()
|
l.next()
|
||||||
l.emit(TIMES)
|
l.emit(TIMES)
|
||||||
return lexNumber
|
return lexValueSequence
|
||||||
case histogramStateAdd:
|
case histogramStateAdd:
|
||||||
l.histogramState = histogramStateNone
|
l.histogramState = histogramStateNone
|
||||||
l.next()
|
l.next()
|
||||||
|
@ -691,6 +691,42 @@ var tests = []struct {
|
|||||||
},
|
},
|
||||||
seriesDesc: true,
|
seriesDesc: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: `{} {{sum:1}}+{{sum:0}}x2 {{sum:1}}+{{sum:0}}x3`,
|
||||||
|
expected: []Item{
|
||||||
|
{LEFT_BRACE, 0, `{`},
|
||||||
|
{RIGHT_BRACE, 1, `}`},
|
||||||
|
{SPACE, 2, ` `},
|
||||||
|
{OPEN_HIST, 3, `{{`},
|
||||||
|
{SUM_DESC, 5, `sum`},
|
||||||
|
{COLON, 8, `:`},
|
||||||
|
{NUMBER, 9, `1`},
|
||||||
|
{CLOSE_HIST, 10, `}}`},
|
||||||
|
{ADD, 12, `+`},
|
||||||
|
{OPEN_HIST, 13, `{{`},
|
||||||
|
{SUM_DESC, 15, `sum`},
|
||||||
|
{COLON, 18, `:`},
|
||||||
|
{NUMBER, 19, `0`},
|
||||||
|
{CLOSE_HIST, 20, `}}`},
|
||||||
|
{TIMES, 22, `x`},
|
||||||
|
{NUMBER, 23, `2`},
|
||||||
|
{SPACE, 24, ` `},
|
||||||
|
{OPEN_HIST, 25, `{{`},
|
||||||
|
{SUM_DESC, 27, `sum`},
|
||||||
|
{COLON, 30, `:`},
|
||||||
|
{NUMBER, 31, `1`},
|
||||||
|
{CLOSE_HIST, 32, `}}`},
|
||||||
|
{ADD, 34, `+`},
|
||||||
|
{OPEN_HIST, 35, `{{`},
|
||||||
|
{SUM_DESC, 37, `sum`},
|
||||||
|
{COLON, 40, `:`},
|
||||||
|
{NUMBER, 41, `0`},
|
||||||
|
{CLOSE_HIST, 42, `}}`},
|
||||||
|
{TIMES, 44, `x`},
|
||||||
|
{NUMBER, 45, `3`},
|
||||||
|
},
|
||||||
|
seriesDesc: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -4371,6 +4371,30 @@ func TestParseHistogramSeries(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "series with two different increments",
|
||||||
|
input: `{} {{sum:1}}+{{sum:1}}x2 {{sum:2}}+{{sum:2}}x2`,
|
||||||
|
expected: []histogram.FloatHistogram{
|
||||||
|
{
|
||||||
|
Sum: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Sum: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Sum: 3,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Sum: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Sum: 4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Sum: 6,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "series with decrement",
|
name: "series with decrement",
|
||||||
input: `{} {{buckets:[5 10 7] schema:1}}-{{buckets:[1 2 3] schema:1}}x2`,
|
input: `{} {{buckets:[5 10 7] schema:1}}-{{buckets:[1 2 3] schema:1}}x2`,
|
||||||
|
@ -57,7 +57,7 @@ clear
|
|||||||
|
|
||||||
# Repeat the same histogram 10 times.
|
# Repeat the same histogram 10 times.
|
||||||
load 5m
|
load 5m
|
||||||
multi_histogram {{schema:0 sum:5 count:4 buckets:[1 2 1]}}x10
|
multi_histogram {{schema:0 sum:5 count:4 buckets:[1 2 1]}}x10 {{schema:0 sum:5 count:4 buckets:[1 2 1]}}+{{}}x10
|
||||||
|
|
||||||
eval instant at 5m histogram_count(multi_histogram)
|
eval instant at 5m histogram_count(multi_histogram)
|
||||||
{} 4
|
{} 4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user