Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[performance] metrics query: range vector support streaming agg when no overlap #7380

Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#### Loki

##### Enhancements
* [7380](https://github.com/grafana/loki/pull/7380) **liguozhong**: metrics query: range vector support streaming agg when no overlap

* [7684](https://github.com/grafana/loki/pull/7684) **kavirajk**: Add missing `embedded-cache` config under `cache_config` doc.
* [6360](https://github.com/grafana/loki/pull/6099) **liguozhong**: Hide error message when ctx timeout occurs in s3.getObject
Expand Down
17 changes: 7 additions & 10 deletions pkg/logql/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,16 +420,15 @@ func rangeAggEvaluator(
q Params,
o time.Duration,
) (StepEvaluator, error) {
agg, err := aggregator(expr)
if err != nil {
return nil, err
}
iter := newRangeVectorIterator(
it,
iter, err := newRangeVectorIterator(
it, expr,
expr.Left.Interval.Nanoseconds(),
q.Step().Nanoseconds(),
q.Start().UnixNano(), q.End().UnixNano(), o.Nanoseconds(),
)
if err != nil {
return nil, err
}
if expr.Operation == syntax.OpRangeTypeAbsent {
return &absentRangeVectorEvaluator{
iter: iter,
Expand All @@ -438,12 +437,10 @@ func rangeAggEvaluator(
}
return &rangeVectorEvaluator{
iter: iter,
agg: agg,
}, nil
}

type rangeVectorEvaluator struct {
agg RangeVectorAggregator
iter RangeVectorIterator

err error
Expand All @@ -454,7 +451,7 @@ func (r *rangeVectorEvaluator) Next() (bool, int64, promql.Vector) {
if !next {
return false, 0, promql.Vector{}
}
ts, vec := r.iter.At(r.agg)
ts, vec := r.iter.At()
for _, s := range vec {
// Errors are not allowed in metrics.
if s.Metric.Has(logqlmodel.ErrorLabel) {
Expand Down Expand Up @@ -486,7 +483,7 @@ func (r *absentRangeVectorEvaluator) Next() (bool, int64, promql.Vector) {
if !next {
return false, 0, promql.Vector{}
}
ts, vec := r.iter.At(one)
ts, vec := r.iter.At()
for _, s := range vec {
// Errors are not allowed in metrics.
if s.Metric.Has(logqlmodel.ErrorLabel) {
Expand Down
Loading