app/vmselect/promql: properly adjust time range for data to select

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/309
This commit is contained in:
Aliaksandr Valialkin 2020-02-05 19:20:54 +02:00
parent 8e77b54846
commit 4a1de7fee9
2 changed files with 9 additions and 3 deletions

View file

@ -635,11 +635,17 @@ func evalRollupFuncWithMetricExpr(ec *EvalConfig, name string, rf rollupFunc,
// Fetch the remaining part of the result. // Fetch the remaining part of the result.
tfs := toTagFilters(me.LabelFilters) tfs := toTagFilters(me.LabelFilters)
minTimestamp := start - maxSilenceInterval
if window > ec.Step {
minTimestamp -= window
} else {
minTimestamp -= ec.Step
}
sq := &storage.SearchQuery{ sq := &storage.SearchQuery{
AccountID: ec.AuthToken.AccountID, AccountID: ec.AuthToken.AccountID,
ProjectID: ec.AuthToken.ProjectID, ProjectID: ec.AuthToken.ProjectID,
MinTimestamp: start - window - maxSilenceInterval, MinTimestamp: minTimestamp,
MaxTimestamp: ec.End + ec.Step, MaxTimestamp: ec.End,
TagFilterss: [][]storage.TagFilter{tfs}, TagFilterss: [][]storage.TagFilter{tfs},
} }
rss, isPartial, err := netstorage.ProcessSearchQuery(ec.AuthToken, sq, true, ec.Deadline) rss, isPartial, err := netstorage.ProcessSearchQuery(ec.AuthToken, sq, true, ec.Deadline)

View file

@ -407,7 +407,7 @@ func (tsm *timeseriesMap) GetOrCreateTimeseries(labelValue string) *timeseries {
// //
// rc.Timestamps are used as timestamps for dstValues. // rc.Timestamps are used as timestamps for dstValues.
// //
// timestamps must cover time range [rc.Start - rc.Window - maxSilenceInterval ... rc.End + rc.Step]. // timestamps must cover time range [rc.Start - rc.Window - maxSilenceInterval ... rc.End].
// //
// Do cannot be called from concurrent goroutines. // Do cannot be called from concurrent goroutines.
func (rc *rollupConfig) Do(dstValues []float64, values []float64, timestamps []int64) []float64 { func (rc *rollupConfig) Do(dstValues []float64, values []float64, timestamps []int64) []float64 {