mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
app/vmselect/promql: allow dropping trailing sample only for default_rollup
function
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/850
This commit is contained in:
parent
3ed9f1d5a9
commit
66de02fbb4
@ -265,6 +265,7 @@ func getRollupConfigs(name string, rf rollupFunc, expr metricsql.Expr, start, en
|
|||||||
Step: step,
|
Step: step,
|
||||||
Window: window,
|
Window: window,
|
||||||
MayAdjustWindow: !rollupFuncsCannotAdjustWindow[name],
|
MayAdjustWindow: !rollupFuncsCannotAdjustWindow[name],
|
||||||
|
CanDropLastSample: name == "default_rollup",
|
||||||
LookbackDelta: lookbackDelta,
|
LookbackDelta: lookbackDelta,
|
||||||
Timestamps: sharedTimestamps,
|
Timestamps: sharedTimestamps,
|
||||||
}
|
}
|
||||||
@ -370,6 +371,11 @@ type rollupConfig struct {
|
|||||||
// when using window smaller than 2 x scrape_interval.
|
// when using window smaller than 2 x scrape_interval.
|
||||||
MayAdjustWindow bool
|
MayAdjustWindow bool
|
||||||
|
|
||||||
|
// Whether the last sample can be dropped during rollup calculations.
|
||||||
|
// The last sample can be dropped for `default_rollup()` function only.
|
||||||
|
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/748 .
|
||||||
|
CanDropLastSample bool
|
||||||
|
|
||||||
Timestamps []int64
|
Timestamps []int64
|
||||||
|
|
||||||
// LoookbackDelta is the analog to `-query.lookback-delta` from Prometheus world.
|
// LoookbackDelta is the analog to `-query.lookback-delta` from Prometheus world.
|
||||||
@ -501,6 +507,7 @@ func (rc *rollupConfig) doInternal(dstValues []float64, tsm *timeseriesMap, valu
|
|||||||
ni := 0
|
ni := 0
|
||||||
nj := 0
|
nj := 0
|
||||||
stalenessInterval := int64(float64(scrapeInterval) * 0.9)
|
stalenessInterval := int64(float64(scrapeInterval) * 0.9)
|
||||||
|
canDropLastSample := rc.CanDropLastSample
|
||||||
for _, tEnd := range rc.Timestamps {
|
for _, tEnd := range rc.Timestamps {
|
||||||
tStart := tEnd - window
|
tStart := tEnd - window
|
||||||
ni = seekFirstTimestampIdxAfter(timestamps[i:], tStart, ni)
|
ni = seekFirstTimestampIdxAfter(timestamps[i:], tStart, ni)
|
||||||
@ -519,7 +526,7 @@ func (rc *rollupConfig) doInternal(dstValues []float64, tsm *timeseriesMap, valu
|
|||||||
}
|
}
|
||||||
rfa.values = values[i:j]
|
rfa.values = values[i:j]
|
||||||
rfa.timestamps = timestamps[i:j]
|
rfa.timestamps = timestamps[i:j]
|
||||||
if j == len(timestamps) && j > 0 && (tEnd-timestamps[j-1] > stalenessInterval || i == j && len(timestamps) == 1) && rc.End-tEnd >= 2*rc.Step {
|
if canDropLastSample && j == len(timestamps) && j > 0 && (tEnd-timestamps[j-1] > stalenessInterval || i == j && len(timestamps) == 1) && rc.End-tEnd >= 2*rc.Step {
|
||||||
// Drop trailing data points in the following cases:
|
// Drop trailing data points in the following cases:
|
||||||
// - if the distance between the last raw sample and tEnd exceeds stalenessInterval
|
// - if the distance between the last raw sample and tEnd exceeds stalenessInterval
|
||||||
// - if time series contains only a single raw sample
|
// - if time series contains only a single raw sample
|
||||||
|
Loading…
Reference in New Issue
Block a user