/
metrics.go
178 lines (174 loc) · 5.23 KB
/
metrics.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package controllers
import (
"github.com/prometheus/client_golang/prometheus"
"sigs.k8s.io/controller-runtime/pkg/metrics"
)
const namespace = "konsumerator"
var (
reconcileTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "reconcile_total",
Help: "Total number of processed reconcile events",
},
[]string{"consumer"},
)
reconcileErrors = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "reconcile_errors_total",
Help: "Total number of errors while processing reconcile events",
},
[]string{"consumer"},
)
reconcileDuration = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "reconcile_duration_seconds",
Help: "Reconcile event duration",
Objectives: map[float64]float64{0.5: 1e-1, 0.9: 1e-2, 0.99: 1e-3, 0.999: 1e-4, 1: 1e-5},
},
[]string{"consumer"},
)
deploymentsCreateTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "deployments_create_total",
Help: "Total number of created deployments",
},
[]string{"consumer"},
)
deploymentsCreateErrors = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "deployments_create_errors",
Help: "Total number of errors while creating deployment",
},
[]string{"consumer"},
)
deploymentsDeleteTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "deployments_delete_total",
Help: "Total number of deleted deployments",
},
[]string{"consumer"},
)
deploymentsDeleteErrors = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "deployments_delete_errors",
Help: "Total number of errors while deleting deployment",
},
[]string{"consumer"},
)
deploymentsUpdateTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "deployments_update_total",
Help: "Total number of updated deployments",
},
[]string{"consumer"},
)
deploymentsUpdateErrors = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "deployments_update_errors",
Help: "Total number of errors while updating deployments",
},
[]string{"consumer"},
)
statusUpdateDuration = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "status_update_duration_seconds",
Help: "Status update duration",
Objectives: map[float64]float64{0.5: 1e-1, 0.9: 1e-2, 0.99: 1e-3, 0.999: 1e-4, 1: 1e-5},
},
[]string{"consumer"},
)
consumerStatus = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "status",
Help: "Consumer deployments status",
},
[]string{"consumer", "type"},
)
deploymentSaturation = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: "deployment",
Name: "saturation",
Help: "Current cpu saturation for deployment",
},
[]string{"consumer", "deployment"},
)
deploymentStatus = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: "deployment",
Name: "status",
Help: "Current deployment status. " +
"1 - RUNNING, 2 - SATURATED, 3 - PENDING_SCALE_UP, 4 - PENDING_SCALE_DOWN, 0 - UNKNOWN",
},
[]string{"consumer", "deployment"},
)
consumerGlobalMemoryPoolSize = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "global_memory_limit_bytes",
Help: "Total amount of bytes for allocation in global limiter",
},
[]string{"consumer"},
)
consumerGlobalCPUPoolSize = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "global_cpu_limit_mcores",
Help: "Total amount of bytes for allocation in global limiter",
},
[]string{"consumer"},
)
consumerGlobalMemoryPoolAllocated = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "global_memory_allocated_bytes",
Help: "Total amount of bytes allocated from the global limiter pool",
},
[]string{"consumer"},
)
consumerGlobalCPUPoolAllocated = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: "consumer",
Name: "global_cpu_allocated_mcores",
Help: "Total number of milli cores allocated from the global limiter pool",
},
[]string{"consumer"},
)
)
func init() {
metrics.Registry.MustRegister(reconcileTotal, reconcileErrors,
reconcileDuration, statusUpdateDuration, consumerStatus,
deploymentsCreateTotal, deploymentsCreateErrors,
deploymentsDeleteTotal, deploymentsDeleteErrors,
deploymentsUpdateTotal, deploymentsUpdateErrors,
deploymentSaturation, deploymentStatus,
consumerGlobalMemoryPoolSize, consumerGlobalCPUPoolSize,
consumerGlobalMemoryPoolAllocated, consumerGlobalCPUPoolAllocated)
}