File: aggr.go

package info (click to toggle)
golang-github-victoriametrics-metricsql 0.10.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 236 kB
  • sloc: makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,155 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package metricsql

import (
	"strings"
)

var aggrFuncs = map[string]bool{
	// See https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators
	"sum":          true,
	"min":          true,
	"max":          true,
	"avg":          true,
	"stddev":       true,
	"stdvar":       true,
	"count":        true,
	"count_values": true,
	"bottomk":      true,
	"topk":         true,
	"quantile":     true,
	"group":        true,

	// MetricsQL extension funcs
	"median":         true,
	"limitk":         true,
	"distinct":       true,
	"sum2":           true,
	"geomean":        true,
	"histogram":      true,
	"topk_min":       true,
	"topk_max":       true,
	"topk_avg":       true,
	"topk_median":    true,
	"bottomk_min":    true,
	"bottomk_max":    true,
	"bottomk_avg":    true,
	"bottomk_median": true,
	"any":            true,
	"outliersk":      true,
	"mode":           true,
	"zscore":         true,
}

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
	}
}