/
autoscaling.go
104 lines (99 loc) · 3.03 KB
/
autoscaling.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
package metrics
import (
"github.com/prometheus/client_golang/prometheus"
"sigs.k8s.io/controller-runtime/pkg/metrics"
)
var (
HPAReplicas = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "crane",
Subsystem: "autoscaling",
Name: "hpa_replicas",
Help: "Replicas for HPA",
},
[]string{"namespace", "name"},
)
EHPAReplicas = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "crane",
Subsystem: "autoscaling",
Name: "effective_hpa_replicas",
Help: "Replicas for Effective HPA",
},
[]string{"namespace", "name"},
)
HPAScaleCount = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "crane",
Subsystem: "autoscaling",
Name: "hpa_scale_count",
Help: "Scale count for HPA",
},
[]string{"namespace", "name", "type"},
)
OOMCount = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "crane",
Subsystem: "autoscaling",
Name: "oom_count",
Help: "The count of pod oom event",
},
[]string{
"namespace",
"pod",
"container",
},
)
EVPACpuScaleUp = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "crane",
Subsystem: "autoscaling",
Name: "effective_vpa_cpu_scale_up",
Help: "The cpu scale up for Effective VPA",
},
[]string{"apiversion", "owner_kind", "namespace", "owner_name", "container", "resource"},
)
EVPACpuScaleDown = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "crane",
Subsystem: "autoscaling",
Name: "effective_vpa_cpu_scale_down",
Help: "The cpu scale down for Effective VPA",
},
[]string{"apiversion", "owner_kind", "namespace", "owner_name", "container", "resource"},
)
EVPAMemoryScaleUp = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "crane",
Subsystem: "autoscaling",
Name: "effective_vpa_memory_scale_up",
Help: "The memory scale up for Effective VPA",
},
[]string{"apiversion", "owner_kind", "namespace", "owner_name", "container", "resource"},
)
EVPAMemoryScaleDown = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "crane",
Subsystem: "autoscaling",
Name: "effective_vpa_memory_scale_down",
Help: "The memory scale down for Effective VPA",
},
[]string{"apiversion", "owner_kind", "namespace", "owner_name", "container", "resource"},
)
EVPAResourceRecommendation = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "crane",
Subsystem: "autoscaling",
Name: "effective_vpa_resource_recommendation",
Help: "The resource recommendation for Effective VPA",
},
[]string{"apiversion", "owner_kind", "namespace", "owner_name", "container", "resource"},
)
)
func init() {
// Register custom metrics with the global prometheus registry
metrics.Registry.MustRegister(HPAReplicas, EHPAReplicas, OOMCount, HPAScaleCount, EVPACpuScaleUp, EVPACpuScaleDown, EVPAMemoryScaleDown, EVPAMemoryScaleUp, EVPAResourceRecommendation)
}
func CustomCollectorRegister(collector ...prometheus.Collector) {
metrics.Registry.MustRegister(collector...)
}