File tree Expand file tree Collapse file tree 4 files changed +62
-2
lines changed
Expand file tree Collapse file tree 4 files changed +62
-2
lines changed Original file line number Diff line number Diff line change @@ -512,7 +512,7 @@ func lexHistogram(l *Lexer) stateFn {
512512 l .histogramState = histogramStateNone
513513 l .next ()
514514 l .emit (TIMES )
515- return lexNumber
515+ return lexValueSequence
516516 case histogramStateAdd :
517517 l .histogramState = histogramStateNone
518518 l .next ()
Original file line number Diff line number Diff line change @@ -691,6 +691,42 @@ var tests = []struct {
691691 },
692692 seriesDesc : true ,
693693 },
694+ {
695+ input : `{} {{sum:1}}+{{sum:0}}x2 {{sum:1}}+{{sum:0}}x3` ,
696+ expected : []Item {
697+ {LEFT_BRACE , 0 , `{` },
698+ {RIGHT_BRACE , 1 , `}` },
699+ {SPACE , 2 , ` ` },
700+ {OPEN_HIST , 3 , `{{` },
701+ {SUM_DESC , 5 , `sum` },
702+ {COLON , 8 , `:` },
703+ {NUMBER , 9 , `1` },
704+ {CLOSE_HIST , 10 , `}}` },
705+ {ADD , 12 , `+` },
706+ {OPEN_HIST , 13 , `{{` },
707+ {SUM_DESC , 15 , `sum` },
708+ {COLON , 18 , `:` },
709+ {NUMBER , 19 , `0` },
710+ {CLOSE_HIST , 20 , `}}` },
711+ {TIMES , 22 , `x` },
712+ {NUMBER , 23 , `2` },
713+ {SPACE , 24 , ` ` },
714+ {OPEN_HIST , 25 , `{{` },
715+ {SUM_DESC , 27 , `sum` },
716+ {COLON , 30 , `:` },
717+ {NUMBER , 31 , `1` },
718+ {CLOSE_HIST , 32 , `}}` },
719+ {ADD , 34 , `+` },
720+ {OPEN_HIST , 35 , `{{` },
721+ {SUM_DESC , 37 , `sum` },
722+ {COLON , 40 , `:` },
723+ {NUMBER , 41 , `0` },
724+ {CLOSE_HIST , 42 , `}}` },
725+ {TIMES , 44 , `x` },
726+ {NUMBER , 45 , `3` },
727+ },
728+ seriesDesc : true ,
729+ },
694730 },
695731 },
696732 {
Original file line number Diff line number Diff line change @@ -4371,6 +4371,30 @@ func TestParseHistogramSeries(t *testing.T) {
43714371 },
43724372 },
43734373 },
4374+ {
4375+ name : "series with two different increments" ,
4376+ input : `{} {{sum:1}}+{{sum:1}}x2 {{sum:2}}+{{sum:2}}x2` ,
4377+ expected : []histogram.FloatHistogram {
4378+ {
4379+ Sum : 1 ,
4380+ },
4381+ {
4382+ Sum : 2 ,
4383+ },
4384+ {
4385+ Sum : 3 ,
4386+ },
4387+ {
4388+ Sum : 2 ,
4389+ },
4390+ {
4391+ Sum : 4 ,
4392+ },
4393+ {
4394+ Sum : 6 ,
4395+ },
4396+ },
4397+ },
43744398 {
43754399 name : "series with decrement" ,
43764400 input : `{} {{buckets:[5 10 7] schema:1}}-{{buckets:[1 2 3] schema:1}}x2` ,
Original file line number Diff line number Diff line change 5757
5858# Repeat the same histogram 10 times.
5959load 5m
60- multi_histogram {{schema:0 sum:5 count:4 buckets:[1 2 1]}}x10
60+ multi_histogram {{schema:0 sum:5 count:4 buckets:[1 2 1]}}x10 {{schema:0 sum:5 count:4 buckets:[1 2 1]}}+{{}}x10
6161
6262eval instant at 5m histogram_count(multi_histogram)
6363 {} 4
You can’t perform that action at this time.
0 commit comments