app/vmselect/promql: reduce the probability of duplicate time series errors when querying Kubernetes metrics

This commit is contained in:
Aliaksandr Valialkin 2021-02-18 22:07:29 +02:00
parent 3a8b2eed58
commit bd1d906eee
2 changed files with 9 additions and 2 deletions

View file

@ -252,16 +252,21 @@ func mergeNonOverlappingTimeseries(dst, src *timeseries) bool {
// Verify whether the time series can be merged. // Verify whether the time series can be merged.
srcValues := src.Values srcValues := src.Values
dstValues := dst.Values dstValues := dst.Values
overlaps := 0
_ = dstValues[len(srcValues)-1] _ = dstValues[len(srcValues)-1]
for i, v := range srcValues { for i, v := range srcValues {
if math.IsNaN(v) { if math.IsNaN(v) {
continue continue
} }
if !math.IsNaN(dstValues[i]) { if !math.IsNaN(dstValues[i]) {
overlaps++
}
}
// Allow up to two overlapping datapoints, which can appear due to staleness algorithm,
// which can add a few datapoints in the end of time series.
if overlaps > 2 {
return false return false
} }
}
// Time series can be merged. Merge them. // Time series can be merged. Merge them.
for i, v := range srcValues { for i, v := range srcValues {
if math.IsNaN(v) { if math.IsNaN(v) {

View file

@ -2,6 +2,8 @@
# tip # tip
* BUGFIX: reduce the probability of `duplicate time series` errors when querying Kubernetes metrics.
# [v1.54.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.54.1) # [v1.54.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.54.1)