Files
Aliaksandr Valialkin 56b399d220 app/vmselect/promql: add outliers_iqr(q) and outlier_iqr_over_time(m[d]) functions
These functions allow detecting anomalies in series and samples using Interquartile range method.
See Outliers section at https://en.wikipedia.org/wiki/Interquartile_range for more details.
2023-10-31 22:10:31 +01:00

62 lines
1.3 KiB
Go

package metricsql
import (
"strings"
)
var aggrFuncs = map[string]bool{
"any": true,
"avg": true,
"bottomk": true,
"bottomk_avg": true,
"bottomk_max": true,
"bottomk_median": true,
"bottomk_last": true,
"bottomk_min": true,
"count": true,
"count_values": true,
"distinct": true,
"geomean": true,
"group": true,
"histogram": true,
"limitk": true,
"mad": true,
"max": true,
"median": true,
"min": true,
"mode": true,
"outliers_iqr": true,
"outliers_mad": true,
"outliersk": true,
"quantile": true,
"quantiles": true,
"share": true,
"stddev": true,
"stdvar": true,
"sum": true,
"sum2": true,
"topk": true,
"topk_avg": true,
"topk_max": true,
"topk_median": true,
"topk_last": true,
"topk_min": true,
"zscore": true,
}
// IsAggrFunc returns whether funcName is a known aggregate function.
func IsAggrFunc(s string) bool {
s = strings.ToLower(s)
return aggrFuncs[s]
}
func isAggrFuncModifier(s string) bool {
s = strings.ToLower(s)
switch s {
case "by", "without":
return true
default:
return false
}
}