mirror of
https://github.com/hanzoai/metrics.git
synced 2026-10-30 20:03:39 +00:00
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.
62 lines
1.3 KiB
Go
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
|
|
}
|
|
}
|