mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #72910 from danielqsj/kn
Add kubelet_node_name metrics
This commit is contained in:
commit
a20cd49d6d
@ -1303,6 +1303,7 @@ func (kl *Kubelet) initializeModules() error {
|
||||
collectors.NewVolumeStatsCollector(kl),
|
||||
collectors.NewLogMetricsCollector(kl.StatsProvider.ListPodStats),
|
||||
)
|
||||
metrics.SetNodeName(kl.nodeName)
|
||||
|
||||
// Setup filesystem directories.
|
||||
if err := kl.setupDataDirs(); err != nil {
|
||||
|
@ -13,6 +13,7 @@ go_library(
|
||||
"//pkg/features:go_default_library",
|
||||
"//pkg/kubelet/container:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
@ -31,6 +32,8 @@ import (
|
||||
|
||||
const (
|
||||
KubeletSubsystem = "kubelet"
|
||||
NodeNameKey = "node_name"
|
||||
NodeLabelKey = "node"
|
||||
PodWorkerLatencyKey = "pod_worker_latency_microseconds"
|
||||
PodStartLatencyKey = "pod_start_latency_microseconds"
|
||||
CgroupManagerOperationsKey = "cgroup_manager_latency_microseconds"
|
||||
@ -65,6 +68,14 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
NodeName = prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Subsystem: KubeletSubsystem,
|
||||
Name: NodeNameKey,
|
||||
Help: "The node's name. The count is always 1.",
|
||||
},
|
||||
[]string{NodeLabelKey},
|
||||
)
|
||||
ContainersPerPodCount = prometheus.NewSummary(
|
||||
prometheus.SummaryOpts{
|
||||
Subsystem: KubeletSubsystem,
|
||||
@ -207,6 +218,7 @@ var registerMetrics sync.Once
|
||||
func Register(containerCache kubecontainer.RuntimeCache, collectors ...prometheus.Collector) {
|
||||
// Register the metrics.
|
||||
registerMetrics.Do(func() {
|
||||
prometheus.MustRegister(NodeName)
|
||||
prometheus.MustRegister(PodWorkerLatency)
|
||||
prometheus.MustRegister(PodStartLatency)
|
||||
prometheus.MustRegister(CgroupManagerLatency)
|
||||
@ -372,3 +384,7 @@ func SetConfigError(err bool) {
|
||||
ConfigError.Set(0)
|
||||
}
|
||||
}
|
||||
|
||||
func SetNodeName(name types.NodeName) {
|
||||
NodeName.WithLabelValues(string(name)).Set(1)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user