-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
prometheus.go
70 lines (61 loc) · 2.11 KB
/
prometheus.go
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package control
import (
"github.com/prometheus/client_golang/prometheus"
)
// controllerMetrics holds metrics related to the query controller.
type ControllerMetrics struct {
Requests *prometheus.CounterVec
NotImplemented *prometheus.CounterVec
RequestsLatency *prometheus.HistogramVec
ExecutingDuration *prometheus.HistogramVec
}
const (
LabelSuccess = "success"
LabelGenericError = "generic_err"
LabelParseErr = "parse_err"
LabelInterruptedErr = "interrupt_err"
LabelRuntimeError = "runtime_error"
LabelNotImplError = "not_implemented"
LabelNotExecuted = "not_executed"
)
func NewControllerMetrics(labels []string) *ControllerMetrics {
const (
namespace = "influxql"
subsystem = "service"
)
return &ControllerMetrics{
Requests: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "requests_total",
Help: "Count of the query requests",
}, append(labels, "result")),
NotImplemented: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "not_implemented_total",
Help: "Count of the query requests executing unimplemented operations",
}, []string{"operation"}),
RequestsLatency: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "requests_latency_seconds",
Help: "Histogram of times spent for end-to-end latency (from issuing query request, to receiving the first byte of the response)",
Buckets: prometheus.ExponentialBuckets(1e-3, 5, 7),
}, append(labels, "result")),
ExecutingDuration: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "executing_duration_seconds",
Help: "Histogram of times spent executing queries",
Buckets: prometheus.ExponentialBuckets(1e-3, 5, 7),
}, append(labels, "result")),
}
}
func (cm *ControllerMetrics) PrometheusCollectors() []prometheus.Collector {
return []prometheus.Collector{
cm.Requests,
cm.NotImplemented,
cm.ExecutingDuration,
}
}