app/vmselect/promql: add deriv_fast function for calculating fast derivative

`deriv_fast` calculates derivative based on the first and the last point on the interval
instead of calculating linear regression based on all the data points on the interval.

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/73
This commit is contained in:
Aliaksandr Valialkin 2019-06-21 23:03:19 +03:00
parent 98eafdbd58
commit c05d443791
2 changed files with 2 additions and 0 deletions

View file

@ -20,6 +20,7 @@ var rollupFuncs = map[string]newRollupFunc{
"changes": newRollupFuncOneArg(rollupChanges), "changes": newRollupFuncOneArg(rollupChanges),
"delta": newRollupFuncOneArg(rollupDelta), "delta": newRollupFuncOneArg(rollupDelta),
"deriv": newRollupFuncOneArg(rollupDerivSlow), "deriv": newRollupFuncOneArg(rollupDerivSlow),
"deriv_fast": newRollupFuncOneArg(rollupDerivFast),
"holt_winters": newRollupHoltWinters, "holt_winters": newRollupHoltWinters,
"idelta": newRollupFuncOneArg(rollupIdelta), "idelta": newRollupFuncOneArg(rollupIdelta),
"increase": newRollupFuncOneArg(rollupDelta), // + rollupFuncsRemoveCounterResets "increase": newRollupFuncOneArg(rollupDelta), // + rollupFuncsRemoveCounterResets

View file

@ -193,6 +193,7 @@ func TestRollupNewRollupFuncSuccess(t *testing.T) {
f("changes", 10) f("changes", 10)
f("delta", -89) f("delta", -89)
f("deriv", -266.85860231406065) f("deriv", -266.85860231406065)
f("deriv_fast", -712)
f("idelta", 0) f("idelta", 0)
f("increase", 275) f("increase", 275)
f("irate", 0) f("irate", 0)