@ -1293,9 +1293,10 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
nil ) ,
nil , nil ) ,
OpRangeTypeCount ,
nil , nil ,
nil ,
nil ,
) ,
} ,
{
@ -1359,7 +1360,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , "" ) ) ,
newUnwrapExpr ( "foo" , "" ) ,
nil ) ,
OpRangeTypeStdvar , nil , nil ,
) ,
} ,
@ -1389,7 +1391,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , OpConvDuration ) ) ,
newUnwrapExpr ( "foo" , OpConvDuration ) ,
nil ) ,
OpRangeTypeStdvar , nil , nil ,
) ,
} ,
@ -1410,7 +1413,30 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , OpConvBytes ) ) ,
newUnwrapExpr ( "foo" , OpConvBytes ) ,
nil ) ,
OpRangeTypeSum , nil , nil ,
) ,
} ,
{
in : ` sum_over_time( { namespace="tns"} |= "level=error" | json |foo>=5,bar<25ms| unwrap bytes(foo) [5m] offset 5m) ` ,
exp : newRangeAggregationExpr (
newLogRange ( & pipelineExpr {
left : newMatcherExpr ( [ ] * labels . Matcher { { Type : labels . MatchEqual , Name : "namespace" , Value : "tns" } } ) ,
pipeline : MultiStageExpr {
newLineFilterExpr ( nil , labels . MatchEqual , "level=error" ) ,
newLabelParserExpr ( OpParserTypeJSON , "" ) ,
& labelFilterExpr {
LabelFilterer : log . NewAndLabelFilter (
log . NewNumericLabelFilter ( log . LabelFilterGreaterThanOrEqual , "foo" , 5 ) ,
log . NewDurationLabelFilter ( log . LabelFilterLesserThan , "bar" , 25 * time . Millisecond ) ,
) ,
} ,
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , OpConvBytes ) ,
newOffsetExpr ( 5 * time . Minute ) ) ,
OpRangeTypeSum , nil , nil ,
) ,
} ,
@ -1431,7 +1457,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "latency" , "" ) ) ,
newUnwrapExpr ( "latency" , "" ) ,
nil ) ,
OpRangeTypeSum , nil , nil ,
) ,
} ,
@ -1452,7 +1479,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "latency" , "" ) ) ,
newUnwrapExpr ( "latency" , "" ) ,
nil ) ,
OpRangeTypeSum , nil , nil ,
) ,
} ,
@ -1466,7 +1494,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "bar" , "" ) ) ,
newUnwrapExpr ( "bar" , "" ) ,
nil ) ,
OpRangeTypeStddev , nil , nil ,
) ,
} ,
@ -1476,7 +1505,8 @@ func TestParse(t *testing.T) {
newLogRange (
newMatcherExpr ( [ ] * labels . Matcher { { Type : labels . MatchEqual , Name : "app" , Value : "foo" } } ) ,
5 * time . Minute ,
newUnwrapExpr ( "bar" , "" ) ) ,
newUnwrapExpr ( "bar" , "" ) ,
nil ) ,
OpRangeTypeMin , nil , nil ,
) ,
} ,
@ -1486,7 +1516,8 @@ func TestParse(t *testing.T) {
newLogRange (
newMatcherExpr ( [ ] * labels . Matcher { { Type : labels . MatchEqual , Name : "app" , Value : "foo" } } ) ,
5 * time . Minute ,
newUnwrapExpr ( "bar" , "" ) ) ,
newUnwrapExpr ( "bar" , "" ) ,
nil ) ,
OpRangeTypeMin , & grouping { } , nil ,
) ,
} ,
@ -1496,7 +1527,8 @@ func TestParse(t *testing.T) {
newLogRange (
newMatcherExpr ( [ ] * labels . Matcher { { Type : labels . MatchEqual , Name : "app" , Value : "foo" } } ) ,
5 * time . Minute ,
newUnwrapExpr ( "bar" , "" ) ) ,
newUnwrapExpr ( "bar" , "" ) ,
nil ) ,
OpRangeTypeMax , & grouping { without : true } , nil ,
) ,
} ,
@ -1506,7 +1538,19 @@ func TestParse(t *testing.T) {
newLogRange (
newMatcherExpr ( [ ] * labels . Matcher { { Type : labels . MatchEqual , Name : "app" , Value : "foo" } } ) ,
5 * time . Minute ,
newUnwrapExpr ( "bar" , "" ) ) ,
newUnwrapExpr ( "bar" , "" ) ,
nil ) ,
OpRangeTypeMax , & grouping { without : true , groups : [ ] string { "foo" , "bar" } } , nil ,
) ,
} ,
{
in : ` max_over_time( { app="foo"} | unwrap bar [5m] offset 5m) without (foo,bar) ` ,
exp : newRangeAggregationExpr (
newLogRange (
newMatcherExpr ( [ ] * labels . Matcher { { Type : labels . MatchEqual , Name : "app" , Value : "foo" } } ) ,
5 * time . Minute ,
newUnwrapExpr ( "bar" , "" ) ,
newOffsetExpr ( 5 * time . Minute ) ) ,
OpRangeTypeMax , & grouping { without : true , groups : [ ] string { "foo" , "bar" } } , nil ,
) ,
} ,
@ -1536,7 +1580,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , "" ) ) ,
newUnwrapExpr ( "foo" , "" ) ,
nil ) ,
OpRangeTypeMax , nil , nil ,
) ,
} ,
@ -1566,7 +1611,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , "" ) ) ,
newUnwrapExpr ( "foo" , "" ) ,
nil ) ,
OpRangeTypeQuantile , nil , NewStringLabelFilter ( "0.99998" ) ,
) ,
} ,
@ -1596,7 +1642,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , "" ) ) ,
newUnwrapExpr ( "foo" , "" ) ,
nil ) ,
OpRangeTypeQuantile , & grouping { without : false , groups : [ ] string { "namespace" , "instance" } } , NewStringLabelFilter ( "0.99998" ) ,
) ,
} ,
@ -1626,7 +1673,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , "" ) . addPostFilter ( log . NewStringLabelFilter ( mustNewMatcher ( labels . MatchNotRegexp , log . ErrorLabel , ".+" ) ) ) ) ,
newUnwrapExpr ( "foo" , "" ) . addPostFilter ( log . NewStringLabelFilter ( mustNewMatcher ( labels . MatchNotRegexp , log . ErrorLabel , ".+" ) ) ) ,
nil ) ,
OpRangeTypeQuantile , & grouping { without : false , groups : [ ] string { "namespace" , "instance" } } , NewStringLabelFilter ( "0.99998" ) ,
) ,
} ,
@ -1660,7 +1708,47 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , "" ) ) ,
newUnwrapExpr ( "foo" , "" ) ,
nil ) ,
OpRangeTypeQuantile , & grouping { without : false , groups : [ ] string { "namespace" , "instance" } } , NewStringLabelFilter ( "0.99998" ) ,
) ,
OpTypeSum ,
& grouping { without : true , groups : [ ] string { "foo" } } ,
nil ,
) ,
} ,
{
in : ` sum without ( foo ) (
quantile_over_time ( 0.99998 , { app = "foo" } |= "bar" | json | latency >= 250 ms or ( status_code < 500 and status_code > 200 )
| line_format "blip{{ .foo }}blop {{.status_code}}" | label_format foo = bar , status_code = "buzz{{.bar}}" | unwrap foo [ 5 m ] offset 5 m
) by ( namespace , instance )
) ` ,
exp : mustNewVectorAggregationExpr (
newRangeAggregationExpr (
newLogRange ( & pipelineExpr {
left : newMatcherExpr ( [ ] * labels . Matcher { { Type : labels . MatchEqual , Name : "app" , Value : "foo" } } ) ,
pipeline : MultiStageExpr {
newLineFilterExpr ( nil , labels . MatchEqual , "bar" ) ,
newLabelParserExpr ( OpParserTypeJSON , "" ) ,
& labelFilterExpr {
LabelFilterer : log . NewOrLabelFilter (
log . NewDurationLabelFilter ( log . LabelFilterGreaterThanOrEqual , "latency" , 250 * time . Millisecond ) ,
log . NewAndLabelFilter (
log . NewNumericLabelFilter ( log . LabelFilterLesserThan , "status_code" , 500.0 ) ,
log . NewNumericLabelFilter ( log . LabelFilterGreaterThan , "status_code" , 200.0 ) ,
) ,
) ,
} ,
newLineFmtExpr ( "blip{{ .foo }}blop {{.status_code}}" ) ,
newLabelFmtExpr ( [ ] log . LabelFmt {
log . NewRenameLabelFmt ( "foo" , "bar" ) ,
log . NewTemplateLabelFmt ( "status_code" , "buzz{{.bar}}" ) ,
} ) ,
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , "" ) ,
newOffsetExpr ( 5 * time . Minute ) ) ,
OpRangeTypeQuantile , & grouping { without : false , groups : [ ] string { "namespace" , "instance" } } , NewStringLabelFilter ( "0.99998" ) ,
) ,
OpTypeSum ,
@ -1698,7 +1786,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , OpConvDuration ) ) ,
newUnwrapExpr ( "foo" , OpConvDuration ) ,
nil ) ,
OpRangeTypeQuantile , & grouping { without : false , groups : [ ] string { "namespace" , "instance" } } , NewStringLabelFilter ( "0.99998" ) ,
) ,
OpTypeSum ,
@ -1736,7 +1825,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , OpConvDuration ) ) ,
newUnwrapExpr ( "foo" , OpConvDuration ) ,
nil ) ,
OpRangeTypeQuantile , & grouping { without : false , groups : [ ] string { "namespace" , "instance" } } , NewStringLabelFilter ( ".99998" ) ,
) ,
OpTypeSum ,
@ -1774,7 +1864,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , OpConvDurationSeconds ) ) ,
newUnwrapExpr ( "foo" , OpConvDurationSeconds ) ,
nil ) ,
OpRangeTypeQuantile , & grouping { without : false , groups : [ ] string { "namespace" , "instance" } } , NewStringLabelFilter ( ".99998" ) ,
) ,
OpTypeSum ,
@ -1812,7 +1903,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , "" ) ) ,
newUnwrapExpr ( "foo" , "" ) ,
nil ) ,
OpRangeTypeQuantile , & grouping { without : false , groups : [ ] string { "namespace" , "instance" } } , NewStringLabelFilter ( "0.99998" ) ,
) ,
OpTypeTopK ,
@ -1859,7 +1951,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , "" ) ) ,
newUnwrapExpr ( "foo" , "" ) ,
nil ) ,
OpRangeTypeQuantile , & grouping { without : false , groups : [ ] string { "namespace" , "instance" } } , NewStringLabelFilter ( "0.99998" ) ,
) ,
OpTypeSum ,
@ -1890,7 +1983,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , "" ) ) ,
newUnwrapExpr ( "foo" , "" ) ,
nil ) ,
OpRangeTypeAvg , & grouping { without : false , groups : [ ] string { "namespace" , "instance" } } , nil ,
) ,
OpTypeAvg ,
@ -1944,7 +2038,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , "" ) ) ,
newUnwrapExpr ( "foo" , "" ) ,
nil ) ,
OpRangeTypeQuantile , & grouping { without : false , groups : [ ] string { "namespace" , "instance" } } , NewStringLabelFilter ( "0.99998" ) ,
) ,
OpTypeSum ,
@ -1975,7 +2070,8 @@ func TestParse(t *testing.T) {
} ,
} ,
5 * time . Minute ,
newUnwrapExpr ( "foo" , "" ) ) ,
newUnwrapExpr ( "foo" , "" ) ,
nil ) ,
OpRangeTypeAvg , & grouping { without : false , groups : [ ] string { "namespace" , "instance" } } , nil ,
) ,
OpTypeAvg ,