Skip to content

Commit 9447fd5

Browse files
Squashed commit of the following:
Author: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> Date: Thu Aug 27 14:10:19 2020 +0300 make the promql lookBack configurable with a flag Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
1 parent 7d7d176 commit 9447fd5

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ We use *breaking :warning:* word for marking changes that are not backward compa
1616
* [#3095](https://github.com/thanos-io/thanos/pull/3095) Rule: update manager when all rule files are removed.
1717
* [#3098](https://github.com/thanos-io/thanos/pull/3098) ui: Fix Block Viewer for Compactor and Store
1818
* [#3105](https://github.com/thanos-io/thanos/pull/3105) Query: Fix overwriting maxSourceResolution when auto downsampling is enabled.
19+
* [#3010](https://github.com/thanos-io/thanos/pull/3010) Querier: Added a flag to override the default look back delta in promql. The flag should be set to at least 2 times the slowest scrape interval.
1920

2021
## [v0.15.0-rc.0](https://github.com/thanos-io/thanos/releases/tag/v0.15.0-rc.0) - 2020.08.26
2122

cmd/thanos/query.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ func registerQuery(m map[string]setupFunc, app *kingpin.Application) {
7070
maxConcurrentQueries := cmd.Flag("query.max-concurrent", "Maximum number of queries processed concurrently by query node.").
7171
Default("20").Int()
7272

73+
lookbackDelta := cmd.Flag("query.lookback-delta", "The maximum lookback duration for retrieving metrics during expression evaluations. For example with a look back of 7min and a scrape interval of 10min, promql will fill in the gap only for 7min and will show the other 3min as a gap. Should be set to at least 2 times the slowest scrape interval.").Duration()
74+
7375
maxConcurrentSelects := cmd.Flag("query.max-concurrent-select", "Maximum number of select requests made concurrently per a query.").
7476
Default("4").Int()
7577

@@ -175,6 +177,7 @@ func registerQuery(m map[string]setupFunc, app *kingpin.Application) {
175177
*maxConcurrentQueries,
176178
*maxConcurrentSelects,
177179
time.Duration(*queryTimeout),
180+
*lookbackDelta,
178181
time.Duration(*defaultEvaluationInterval),
179182
time.Duration(*storeResponseTimeout),
180183
*queryReplicaLabels,
@@ -222,6 +225,7 @@ func runQuery(
222225
maxConcurrentQueries int,
223226
maxConcurrentSelects int,
224227
queryTimeout time.Duration,
228+
lookbackDelta time.Duration,
225229
defaultEvaluationInterval time.Duration,
226230
storeResponseTimeout time.Duration,
227231
queryReplicaLabels []string,
@@ -312,6 +316,7 @@ func runQuery(
312316
NoStepSubqueryIntervalFn: func(rangeMillis int64) int64 {
313317
return defaultEvaluationInterval.Milliseconds()
314318
},
319+
LookbackDelta: lookbackDelta,
315320
},
316321
)
317322
)

docs/components/query.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,14 @@ Flags:
367367
--query.timeout=2m Maximum time to process query by query node.
368368
--query.max-concurrent=20 Maximum number of queries processed
369369
concurrently by query node.
370+
--query.lookback-delta=QUERY.LOOKBACK-DELTA
371+
The maximum lookback duration for retrieving
372+
metrics during expression evaluations. For
373+
example with a look back of 7min and a scrape
374+
interval of 10min, promql will fill in the gap
375+
only for 7min and will show the other 3min as a
376+
gap. Should be set to at least 2 times the
377+
slowest scrape interval.
370378
--query.max-concurrent-select=4
371379
Maximum number of select requests made
372380
concurrently per a query.

pkg/query/iter.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ type chunkSeriesIterator struct {
302302
func newChunkSeriesIterator(cs []chunkenc.Iterator) chunkenc.Iterator {
303303
if len(cs) == 0 {
304304
// This should not happen. StoreAPI implementations should not send empty results.
305-
return errSeriesIterator{}
305+
return errSeriesIterator{err: errors.Errorf("store returned an empty result")}
306306
}
307307
return &chunkSeriesIterator{chunks: cs}
308308
}
@@ -503,7 +503,8 @@ func (it noopAdjustableSeriesIterator) adjustAtValue(float64) {}
503503
// Replica 1 counter scrapes: 20 30 40 Nan - 0 5
504504
// Replica 2 counter scrapes: 25 35 45 Nan - 2
505505
//
506-
// Now for downsampling purposes we are accounting the resets so our replicas before going to dedup iterator looks like this:
506+
// Now for downsampling purposes we are accounting the resets(rewriting the samples value)
507+
// so our replicas before going to dedup iterator looks like this:
507508
//
508509
// Replica 1 counter total: 20 30 40 - - 40 45
509510
// Replica 2 counter total: 25 35 45 - - 47
@@ -648,7 +649,7 @@ func (it *dedupSeriesIterator) Seek(t int64) bool {
648649
// Don't use underlying Seek, but iterate over next to not miss gaps.
649650
for {
650651
ts, _ := it.At()
651-
if ts > 0 && ts >= t {
652+
if ts >= t {
652653
return true
653654
}
654655
if !it.Next() {

0 commit comments

Comments
 (0)