1
16
17 package metrics
18
19 import (
20 "github.com/prometheus/client_golang/prometheus"
21 "github.com/prometheus/client_golang/prometheus/collectors"
22 "sigs.k8s.io/controller-runtime/pkg/metrics"
23 )
24
25 var (
26
27
28
29
30 ReconcileTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
31 Name: "controller_runtime_reconcile_total",
32 Help: "Total number of reconciliations per controller",
33 }, []string{"controller", "result"})
34
35
36
37 ReconcileErrors = prometheus.NewCounterVec(prometheus.CounterOpts{
38 Name: "controller_runtime_reconcile_errors_total",
39 Help: "Total number of reconciliation errors per controller",
40 }, []string{"controller"})
41
42
43
44 TerminalReconcileErrors = prometheus.NewCounterVec(prometheus.CounterOpts{
45 Name: "controller_runtime_terminal_reconcile_errors_total",
46 Help: "Total number of terminal reconciliation errors per controller",
47 }, []string{"controller"})
48
49
50
51 ReconcileTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
52 Name: "controller_runtime_reconcile_time_seconds",
53 Help: "Length of time per reconciliation per controller",
54 Buckets: []float64{0.005, 0.01, 0.025, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0,
55 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40, 50, 60},
56 }, []string{"controller"})
57
58
59
60 WorkerCount = prometheus.NewGaugeVec(prometheus.GaugeOpts{
61 Name: "controller_runtime_max_concurrent_reconciles",
62 Help: "Maximum number of concurrent reconciles per controller",
63 }, []string{"controller"})
64
65
66
67 ActiveWorkers = prometheus.NewGaugeVec(prometheus.GaugeOpts{
68 Name: "controller_runtime_active_workers",
69 Help: "Number of currently used workers per controller",
70 }, []string{"controller"})
71 )
72
73 func init() {
74 metrics.Registry.MustRegister(
75 ReconcileTotal,
76 ReconcileErrors,
77 TerminalReconcileErrors,
78 ReconcileTime,
79 WorkerCount,
80 ActiveWorkers,
81
82 collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}),
83
84 collectors.NewGoCollector(),
85 )
86 }
87
View as plain text