diff --git a/Gopkg.lock b/Gopkg.lock index 7e347864d..05b3ad688 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -492,7 +492,7 @@ "web/api/v2", "web/ui" ] - revision = "a3e3839bb7043dbbbc74accf02cf152eb2f5609f" + revision = "9afbbc0c5df386ab546cb8522fa3dc132eb2650b" source = "github.com/jacksontj/prometheus" [[projects]] diff --git a/vendor/github.com/prometheus/prometheus/promql/engine.go b/vendor/github.com/prometheus/prometheus/promql/engine.go index 21c5a189d..bff0ab8fd 100644 --- a/vendor/github.com/prometheus/prometheus/promql/engine.go +++ b/vendor/github.com/prometheus/prometheus/promql/engine.go @@ -471,6 +471,8 @@ func (ng *Engine) execEvalStmt(ctx context.Context, query *query, s *EvalStmt) ( func (ng *Engine) populateIterators(ctx context.Context, q storage.Queryable, s *EvalStmt) (storage.Querier, error) { var maxOffset time.Duration + + offsets := make(map[time.Duration]struct{}) // In this for Inspect parallelizes on BinaryExpr l := sync.Mutex{} Inspect(ctx, s, func(node Node, _ []Node) error { @@ -481,15 +483,21 @@ func (ng *Engine) populateIterators(ctx context.Context, q storage.Queryable, s if maxOffset < LookbackDelta { maxOffset = LookbackDelta } - if n.Offset+LookbackDelta > maxOffset { - maxOffset = n.Offset + LookbackDelta + if LookbackDelta > maxOffset { + maxOffset = LookbackDelta + } + if n.Offset > 0 { + offsets[n.Offset] = struct{}{} } case *MatrixSelector: if maxOffset < n.Range { maxOffset = n.Range } - if n.Offset+n.Range > maxOffset { - maxOffset = n.Offset + n.Range + if n.Range > maxOffset { + maxOffset = n.Range + } + if n.Offset > 0 { + offsets[n.Offset] = struct{}{} } } return nil @@ -502,6 +510,15 @@ func (ng *Engine) populateIterators(ctx context.Context, q storage.Queryable, s return nil, err } + offsetQueriers := make(map[time.Duration]storage.Querier) + for offset, _ := range offsets { + querier, err := q.Querier(ctx, timestamp.FromTime(mint.Add(-offset)), timestamp.FromTime(s.End.Add(-offset))) + if err != nil { + return nil, err + } + offsetQueriers[offset] = querier + } + n, err := Inspect(ctx, s, func(node Node, path []Node) error { params := &storage.SelectParams{ Step: int64(s.Interval / time.Millisecond), @@ -511,11 +528,13 @@ func (ng *Engine) populateIterators(ctx context.Context, q storage.Queryable, s case *VectorSelector: if n.series == nil { params.Func = extractFuncFromPath(path) + + q := querier if n.Offset > 0 { - params.Offset = int64(n.Offset / time.Millisecond) + q = offsetQueriers[n.Offset] } - set, err := querier.Select(params, n.LabelMatchers...) + set, err := q.Select(params, n.LabelMatchers...) if err != nil { level.Error(ng.logger).Log("msg", "error selecting series set", "err", err) return err @@ -535,11 +554,13 @@ func (ng *Engine) populateIterators(ctx context.Context, q storage.Queryable, s case *MatrixSelector: if n.series == nil { params.Func = extractFuncFromPath(path) + + q := querier if n.Offset > 0 { - params.Offset = int64(n.Offset / time.Millisecond) + q = offsetQueriers[n.Offset] } - set, err := querier.Select(params, n.LabelMatchers...) + set, err := q.Select(params, n.LabelMatchers...) if err != nil { level.Error(ng.logger).Log("msg", "error selecting series set", "err", err) return err diff --git a/vendor/github.com/prometheus/prometheus/storage/interface.go b/vendor/github.com/prometheus/prometheus/storage/interface.go index 8a5653c16..9c145c425 100644 --- a/vendor/github.com/prometheus/prometheus/storage/interface.go +++ b/vendor/github.com/prometheus/prometheus/storage/interface.go @@ -63,9 +63,8 @@ type Querier interface { // SelectParams specifies parameters passed to data selections. type SelectParams struct { - Step int64 // Query step size in milliseconds. - Func string // String representation of surrounding function or aggregation. - Offset int64 // Offset in milliseconds for this particular select statement + Step int64 // Query step size in milliseconds. + Func string // String representation of surrounding function or aggregation. } // QueryableFunc is an adapter to allow the use of ordinary functions as diff --git a/vendor/github.com/prometheus/prometheus/storage/remote/read.go b/vendor/github.com/prometheus/prometheus/storage/remote/read.go index 598ed3cd0..1fedad884 100644 --- a/vendor/github.com/prometheus/prometheus/storage/remote/read.go +++ b/vendor/github.com/prometheus/prometheus/storage/remote/read.go @@ -43,8 +43,8 @@ type querier struct { // Select implements storage.Querier and uses the given matchers to read series // sets from the Client. -func (q *querier) Select(p *storage.SelectParams, matchers ...*labels.Matcher) (storage.SeriesSet, error) { - query, err := ToQuery(q.mint, q.maxt-p.Offset, matchers) +func (q *querier) Select(_ *storage.SelectParams, matchers ...*labels.Matcher) (storage.SeriesSet, error) { + query, err := ToQuery(q.mint, q.maxt, matchers) if err != nil { return nil, err }