diff --git a/pkg/logql/engine_test.go b/pkg/logql/engine_test.go index 4e714671e1815..73d03731757eb 100644 --- a/pkg/logql/engine_test.go +++ b/pkg/logql/engine_test.go @@ -348,7 +348,7 @@ func TestEngine_InstantQuery(t *testing.T) { {&logproto.QueryRequest{Direction: logproto.FORWARD, Start: time.Unix(0, 0), End: time.Unix(60, 0), Selector: `{app="foo"}`}}, }, promql.Vector{ - promql.Sample{Point: promql.Point{T: 60 * 1000, V: 1}, Metric: labels.Labels{labels.Label{Name: "app", Value: "foo"}}}, + promql.Sample{Point: promql.Point{T: 60 * 1000, V: 60}, Metric: labels.Labels{labels.Label{Name: "app", Value: "foo"}}}, }, }, { @@ -1348,7 +1348,37 @@ func TestEngine_RangeQuery(t *testing.T) { promql.Matrix{ promql.Series{ Metric: labels.Labels{{Name: "app", Value: "foo"}}, - Points: []promql.Point{{T: 60 * 1000, V: 1.}, {T: 105 * 1000, V: 1.}, {T: 120 * 1000, V: 1.}}, + Points: []promql.Point{{T: 60 * 1000, V: 5.}, {T: 105 * 1000, V: 4.}, {T: 120 * 1000, V: 4.}}, + }, + }, + }, + { + `bytes_over_time({app="foo"}[30s]) > bool 1`, time.Unix(60, 0), time.Unix(120, 0), 15 * time.Second, 0, logproto.FORWARD, 10, + [][]logproto.Stream{ + {logproto.Stream{ + Labels: `{app="foo"}`, + Entries: []logproto.Entry{ + {Timestamp: time.Unix(45, 0), Line: "01234"}, // 5 bytes + {Timestamp: time.Unix(60, 0), Line: ""}, + {Timestamp: time.Unix(75, 0), Line: ""}, + {Timestamp: time.Unix(90, 0), Line: ""}, + {Timestamp: time.Unix(105, 0), Line: "0123"}, // 4 bytes + }, + }}, + }, + []SelectParams{ + {&logproto.QueryRequest{Direction: logproto.FORWARD, Start: time.Unix(30, 0), End: time.Unix(120, 0), Limit: 0, Selector: `{app="foo"}`}}, + }, + promql.Matrix{ + promql.Series{ + Metric: labels.Labels{labels.Label{Name: "app", Value: "foo"}}, + Points: []promql.Point{ + {T: 60000, V: 1}, + {T: 75000, V: 0}, + {T: 90000, V: 0}, + {T: 105000, V: 1}, + {T: 120000, V: 1}, + }, }, }, }, diff --git a/pkg/logql/evaluator.go b/pkg/logql/evaluator.go index bdddf8062f523..2244c539836b6 100644 --- a/pkg/logql/evaluator.go +++ b/pkg/logql/evaluator.go @@ -825,7 +825,7 @@ func literalStepEvaluator( left, right, !returnBool, - false, + IsComparisonOperator(op), ); merged != nil { results = append(results, *merged) } diff --git a/pkg/querier/queryrange/downstreamer.go b/pkg/querier/queryrange/downstreamer.go index b5700fa032535..c494790a13fa4 100644 --- a/pkg/querier/queryrange/downstreamer.go +++ b/pkg/querier/queryrange/downstreamer.go @@ -60,7 +60,7 @@ func (in instance) Downstream(ctx context.Context, queries []logql.DownstreamQue req := ParamsToLokiRequest(qry.Params).WithShards(qry.Shards).WithQuery(qry.Expr.String()).(*LokiRequest) logger, ctx := spanlogger.New(ctx, "DownstreamHandler.instance") defer logger.Finish() - level.Debug(logger).Log("shards", req.Shards, "query", req.Query) + level.Debug(logger).Log("shards", fmt.Sprintf("%+v", req.Shards), "query", req.Query) res, err := in.handler.Do(ctx, req) if err != nil {