2019-12-25 19:35:47 +00:00
|
|
|
package metricsql
|
2019-12-08 22:52:31 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
var transformFuncs = map[string]bool{
|
|
|
|
// Standard promql funcs
|
|
|
|
// See funcs accepting instant-vector on https://prometheus.io/docs/prometheus/latest/querying/functions/ .
|
|
|
|
"abs": true,
|
|
|
|
"absent": true,
|
|
|
|
"ceil": true,
|
|
|
|
"clamp_max": true,
|
|
|
|
"clamp_min": true,
|
|
|
|
"day_of_month": true,
|
|
|
|
"day_of_week": true,
|
|
|
|
"days_in_month": true,
|
|
|
|
"exp": true,
|
|
|
|
"floor": true,
|
|
|
|
"histogram_quantile": true,
|
|
|
|
"hour": true,
|
|
|
|
"label_join": true,
|
|
|
|
"label_replace": true,
|
|
|
|
"ln": true,
|
|
|
|
"log2": true,
|
|
|
|
"log10": true,
|
|
|
|
"minute": true,
|
|
|
|
"month": true,
|
|
|
|
"round": true,
|
|
|
|
"scalar": true,
|
|
|
|
"sort": true,
|
|
|
|
"sort_desc": true,
|
|
|
|
"sqrt": true,
|
|
|
|
"time": true,
|
|
|
|
"timestamp": true,
|
|
|
|
"vector": true,
|
|
|
|
"year": true,
|
|
|
|
|
2019-12-25 19:35:47 +00:00
|
|
|
// New funcs from MetricsQL
|
2019-12-08 22:52:31 +00:00
|
|
|
"label_set": true,
|
|
|
|
"label_del": true,
|
|
|
|
"label_keep": true,
|
|
|
|
"label_copy": true,
|
|
|
|
"label_move": true,
|
|
|
|
"label_transform": true,
|
|
|
|
"label_value": true,
|
2020-01-21 13:00:13 +00:00
|
|
|
"label_match": true,
|
|
|
|
"label_mismatch": true,
|
2019-12-08 22:52:31 +00:00
|
|
|
"union": true,
|
2019-12-25 19:35:47 +00:00
|
|
|
"": true, // empty func is a synonim to union
|
2019-12-08 22:52:31 +00:00
|
|
|
"keep_last_value": true,
|
2020-01-28 22:47:42 +00:00
|
|
|
"keep_next_value": true,
|
2019-12-08 22:52:31 +00:00
|
|
|
"start": true,
|
|
|
|
"end": true,
|
|
|
|
"step": true,
|
|
|
|
"running_sum": true,
|
|
|
|
"running_max": true,
|
|
|
|
"running_min": true,
|
|
|
|
"running_avg": true,
|
|
|
|
"range_sum": true,
|
|
|
|
"range_max": true,
|
|
|
|
"range_min": true,
|
|
|
|
"range_avg": true,
|
|
|
|
"range_first": true,
|
|
|
|
"range_last": true,
|
|
|
|
"range_quantile": true,
|
|
|
|
"smooth_exponential": true,
|
|
|
|
"remove_resets": true,
|
|
|
|
"rand": true,
|
|
|
|
"rand_normal": true,
|
|
|
|
"rand_exponential": true,
|
|
|
|
"pi": true,
|
|
|
|
"sin": true,
|
|
|
|
"cos": true,
|
|
|
|
"asin": true,
|
|
|
|
"acos": true,
|
|
|
|
"prometheus_buckets": true,
|
2020-01-04 10:44:09 +00:00
|
|
|
"histogram_share": true,
|
2019-12-08 22:52:31 +00:00
|
|
|
}
|
|
|
|
|
2020-01-04 11:24:57 +00:00
|
|
|
// IsTransformFunc returns whether funcName is known transform function.
|
|
|
|
func IsTransformFunc(funcName string) bool {
|
|
|
|
s := strings.ToLower(funcName)
|
2019-12-08 22:52:31 +00:00
|
|
|
return transformFuncs[s]
|
2020-01-04 11:24:57 +00:00
|
|
|
|
2019-12-08 22:52:31 +00:00
|
|
|
}
|