app/vmselect/promql: return continuous values for min_over_time and max_over_time when step is smaller than scrape_interval

This commit is contained in:
Aliaksandr Valialkin 2020-01-11 12:47:29 +02:00
parent 92e00779fa
commit fc01b11ddc

View File

@ -105,17 +105,26 @@ var rollupAggrFuncs = map[string]rollupFunc{
"tmax_over_time": rollupTmax, "tmax_over_time": rollupTmax,
} }
var rollupFuncsMayAdjustWindow = map[string]bool{ var rollupFuncsCannotAdjustWindow = map[string]bool{
"default_rollup": true, "changes": true,
"first_over_time": true, "delta": true,
"last_over_time": true, "holt_winters": true,
"deriv": true, "idelta": true,
"deriv_fast": true, "increase": true,
"irate": true, "predict_linear": true,
"rate": true, "resets": true,
"lifetime": true, "sum_over_time": true,
"lag": true, "count_over_time": true,
"scrape_interval": true, "quantile_over_time": true,
"stddev_over_time": true,
"stdvar_over_time": true,
"absent_over_time": true,
"sum2_over_time": true,
"geomean_over_time": true,
"distinct_over_time": true,
"increases_over_time": true,
"decreases_over_time": true,
"integrate": true,
} }
var rollupFuncsRemoveCounterResets = map[string]bool{ var rollupFuncsRemoveCounterResets = map[string]bool{
@ -214,7 +223,7 @@ func getRollupConfigs(name string, rf rollupFunc, expr metricsql.Expr, start, en
End: end, End: end,
Step: step, Step: step,
Window: window, Window: window,
MayAdjustWindow: rollupFuncsMayAdjustWindow[name], MayAdjustWindow: !rollupFuncsCannotAdjustWindow[name],
LookbackDelta: lookbackDelta, LookbackDelta: lookbackDelta,
Timestamps: sharedTimestamps, Timestamps: sharedTimestamps,
} }
@ -873,7 +882,10 @@ func rollupAvg(rfa *rollupFuncArg) float64 {
// before calling rollup funcs. // before calling rollup funcs.
values := rfa.values values := rfa.values
if len(values) == 0 { if len(values) == 0 {
return rfa.prevValue // Do not take into account rfa.prevValue, since it may lead
// to inconsistent results comparing to Prometheus on broken time series
// with irregular data points.
return nan
} }
var sum float64 var sum float64
for _, v := range values { for _, v := range values {