app/vmselect/promql: tune automatic window adjustement

Increase the windows adjustement for small scrape intervals,
since they usually have higher jitter.

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/139
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/134
This commit is contained in:
Aliaksandr Valialkin 2019-08-04 19:32:18 +03:00
parent 1d4ddadbb1
commit 000c154641
2 changed files with 25 additions and 8 deletions

View File

@ -231,10 +231,27 @@ func getMaxPrevInterval(timestamps []int64) int64 {
}
d := (timestamps[len(timestamps)-1] - timestamps[0]) / int64(len(timestamps)-1)
if d <= 0 {
return 1
return int64(maxSilenceInterval)
}
// Slightly increase d in order to handle possible jitter in scrape interval.
return d + (d / 4)
// Increase d more for smaller scrape intervals in order to hide possible gaps
// when high jitter is present.
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/139 .
if d <= 2*1000 {
return d + 4*d
}
if d <= 4*1000 {
return d + 2*d
}
if d <= 8*1000 {
return d + d
}
if d <= 16*1000 {
return d + d/2
}
if d <= 32*1000 {
return d + d/4
}
return d + d/8
}
func removeCounterResets(values []float64) {

View File

@ -347,7 +347,7 @@ func TestRollupNoWindowNoPoints(t *testing.T) {
}
rc.Timestamps = getTimestamps(rc.Start, rc.End, rc.Step)
values := rc.Do(nil, testValues, testTimestamps)
valuesExpected := []float64{2, 0, 0, 0, 0, 0, 0, nan}
valuesExpected := []float64{2, 0, 0, 0, 0, 0, 0, 0}
timestampsExpected := []int64{120, 124, 128, 132, 136, 140, 144, 148}
testRowsEqual(t, values, rc.Timestamps, valuesExpected, timestampsExpected)
})
@ -371,15 +371,15 @@ func TestRollupWindowNoPoints(t *testing.T) {
t.Run("afterEnd", func(t *testing.T) {
rc := rollupConfig{
Func: rollupFirst,
Start: 141,
End: 171,
Start: 161,
End: 191,
Step: 10,
Window: 3,
}
rc.Timestamps = getTimestamps(rc.Start, rc.End, rc.Step)
values := rc.Do(nil, testValues, testTimestamps)
valuesExpected := []float64{34, nan, nan, nan}
timestampsExpected := []int64{141, 151, 161, 171}
valuesExpected := []float64{34, 34, 34, nan}
timestampsExpected := []int64{161, 171, 181, 191}
testRowsEqual(t, values, rc.Timestamps, valuesExpected, timestampsExpected)
})
}