mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/promql: do not return data points in the end of the selected time range for time series ending in the middle of the selected time range
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/887 Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/845
This commit is contained in:
parent
6385432611
commit
8f3339fa81
2 changed files with 7 additions and 3 deletions
|
@ -507,7 +507,9 @@ 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
|
// Do not drop trailing data points for queries, which return 2 or 1 point (aka instant queries).
|
||||||
|
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/845
|
||||||
|
canDropLastSample := rc.CanDropLastSample && len(rc.Timestamps) > 2
|
||||||
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)
|
||||||
|
@ -526,13 +528,12 @@ 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 canDropLastSample && 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) {
|
||||||
// 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
|
||||||
// This should prevent from double counting when a label changes in time series (for instance,
|
// This should prevent from double counting when a label changes in time series (for instance,
|
||||||
// during new deployment in K8S). See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/748
|
// during new deployment in K8S). See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/748
|
||||||
// Do not drop trailing data points for instant queries. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/845
|
|
||||||
rfa.prevValue = nan
|
rfa.prevValue = nan
|
||||||
rfa.values = nil
|
rfa.values = nil
|
||||||
rfa.timestamps = nil
|
rfa.timestamps = nil
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/825#issuecomment-724308361 for details.
|
See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/825#issuecomment-724308361 for details.
|
||||||
* FEATURE: vmalert: explicitly set extra labels to alert entities. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/870
|
* FEATURE: vmalert: explicitly set extra labels to alert entities. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/870
|
||||||
|
|
||||||
|
* BUGFIX: do not return data points in the end of the selected time range for time series ending in the middle of the selected time range.
|
||||||
|
See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/887 and https://github.com/VictoriaMetrics/VictoriaMetrics/issues/845
|
||||||
|
|
||||||
|
|
||||||
# [v1.46.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.46.0)
|
# [v1.46.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.46.0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue