Fix vector-scalar comparisons (#2189)

* fmts shards in instance logger

* vector-scalar comparisons now filter by default

* gofmt
pull/2196/head
Owen Diehl 6 years ago committed by GitHub
parent 1530120c2e
commit 61fc175361
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 34
      pkg/logql/engine_test.go
  2. 2
      pkg/logql/evaluator.go
  3. 2
      pkg/querier/queryrange/downstreamer.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},
},
},
},
},

@ -825,7 +825,7 @@ func literalStepEvaluator(
left,
right,
!returnBool,
false,
IsComparisonOperator(op),
); merged != nil {
results = append(results, *merged)
}

@ -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 {

Loading…
Cancel
Save