-
Notifications
You must be signed in to change notification settings - Fork 332
/
node.go
83 lines (75 loc) · 2.73 KB
/
node.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
package metrics
import (
"runtime"
"sync"
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config"
"github.com/prometheus/client_golang/prometheus"
)
// MetricCNIRequestDuration is a prometheus metric that tracks the duration
// of CNI requests
var MetricCNIRequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: MetricOvnkubeNamespace,
Subsystem: MetricOvnkubeSubsystemNode,
Name: "cni_request_duration_seconds",
Help: "The duration of CNI server requests.",
Buckets: prometheus.ExponentialBuckets(.1, 2, 15)},
//labels
[]string{"command", "err"},
)
var MetricNodeReadyDuration = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: MetricOvnkubeNamespace,
Subsystem: MetricOvnkubeSubsystemNode,
Name: "ready_duration_seconds",
Help: "The duration for the node to get to ready state.",
})
var metricOvnNodePortEnabled = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: MetricOvnkubeNamespace,
Subsystem: MetricOvnkubeSubsystemNode,
Name: "nodeport_enabled",
Help: "Specifies if the node port is enabled on this node(1) or not(0).",
})
// metric to get the size of ovnkube.log file
var metricOvnKubeNodeLogFileSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: MetricOvnkubeNamespace,
Subsystem: MetricOvnkubeSubsystemNode,
Name: "logfile_size_bytes",
Help: "The size of ovnkube logfile on the node."},
[]string{
"logfile_name",
},
)
var registerNodeMetricsOnce sync.Once
func RegisterNodeMetrics(stopChan <-chan struct{}) {
registerNodeMetricsOnce.Do(func() {
// ovnkube-node metrics
prometheus.MustRegister(MetricCNIRequestDuration)
prometheus.MustRegister(MetricNodeReadyDuration)
prometheus.MustRegister(metricOvnNodePortEnabled)
prometheus.MustRegister(prometheus.NewGaugeFunc(
prometheus.GaugeOpts{
Namespace: MetricOvnkubeNamespace,
Subsystem: MetricOvnkubeSubsystemNode,
Name: "build_info",
Help: "A metric with a constant '1' value labeled by version, revision, branch, " +
"and go version from which ovnkube was built and when and who built it.",
ConstLabels: prometheus.Labels{
"version": "0.0",
"revision": config.Commit,
"branch": config.Branch,
"build_user": config.BuildUser,
"build_date": config.BuildDate,
"goversion": runtime.Version(),
},
},
func() float64 { return 1 },
))
registerWorkqueueMetrics(MetricOvnkubeNamespace, MetricOvnkubeSubsystemNode)
if err := prometheus.Register(MetricResourceRetryFailuresCount); err != nil {
if _, ok := err.(prometheus.AlreadyRegisteredError); !ok {
panic(err)
}
}
prometheus.MustRegister(metricOvnKubeNodeLogFileSize)
go ovnKubeLogFileSizeMetricsUpdater(metricOvnKubeNodeLogFileSize, stopChan)
})
}