mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-24 03:18:57 +00:00
Merge pull request #99000 from verb/1.21-kubelet-metrics
Add kubelet metrics for ephemeral containers
This commit is contained in:
@@ -83,6 +83,20 @@ const (
|
||||
// Metrics keys for RuntimeClass
|
||||
RunPodSandboxDurationKey = "run_podsandbox_duration_seconds"
|
||||
RunPodSandboxErrorsKey = "run_podsandbox_errors_total"
|
||||
|
||||
// Metrics to keep track of total number of Pods and Containers started
|
||||
StartedPodsTotalKey = "started_pods_total"
|
||||
StartedPodsErrorsTotalKey = "started_pods_errors_total"
|
||||
StartedContainersTotalKey = "started_containers_total"
|
||||
StartedContainersErrorsTotalKey = "started_containers_errors_total"
|
||||
|
||||
// Metrics to track ephemeral container usage by this kubelet
|
||||
ManagedEphemeralContainersKey = "managed_ephemeral_containers"
|
||||
|
||||
// Values used in metric labels
|
||||
Container = "container"
|
||||
InitContainer = "init_container"
|
||||
EphemeralContainer = "ephemeral_container"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -436,6 +450,54 @@ var (
|
||||
},
|
||||
[]string{"container_state"},
|
||||
)
|
||||
// StartedPodsTotal is a counter that tracks pod sandbox creation operations
|
||||
StartedPodsTotal = metrics.NewCounter(
|
||||
&metrics.CounterOpts{
|
||||
Subsystem: KubeletSubsystem,
|
||||
Name: StartedPodsTotalKey,
|
||||
Help: "Cumulative number of pods started",
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
)
|
||||
// StartedPodsErrorsTotal is a counter that tracks the number of errors creating pod sandboxes
|
||||
StartedPodsErrorsTotal = metrics.NewCounterVec(
|
||||
&metrics.CounterOpts{
|
||||
Subsystem: KubeletSubsystem,
|
||||
Name: StartedPodsErrorsTotalKey,
|
||||
Help: "Cumulative number of errors when starting pods",
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
[]string{"message"},
|
||||
)
|
||||
// StartedContainersTotal is a counter that tracks the number of container creation operations
|
||||
StartedContainersTotal = metrics.NewCounterVec(
|
||||
&metrics.CounterOpts{
|
||||
Subsystem: KubeletSubsystem,
|
||||
Name: StartedContainersTotalKey,
|
||||
Help: "Cumulative number of containers started",
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
[]string{"container_type"},
|
||||
)
|
||||
// StartedContainersTotal is a counter that tracks the number of errors creating containers
|
||||
StartedContainersErrorsTotal = metrics.NewCounterVec(
|
||||
&metrics.CounterOpts{
|
||||
Subsystem: KubeletSubsystem,
|
||||
Name: StartedContainersErrorsTotalKey,
|
||||
Help: "Cumulative number of errors when starting containers",
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
[]string{"container_type", "code"},
|
||||
)
|
||||
// ManagedEphemeralContainers is a gauge that indicates how many ephemeral containers are managed by this kubelet.
|
||||
ManagedEphemeralContainers = metrics.NewGauge(
|
||||
&metrics.GaugeOpts{
|
||||
Subsystem: KubeletSubsystem,
|
||||
Name: ManagedEphemeralContainersKey,
|
||||
Help: "Current number of ephemeral containers in pods managed by this kubelet. Ephemeral containers will be ignored if disabled by the EphemeralContainers feature gate, and this number will be 0.",
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
var registerMetrics sync.Once
|
||||
@@ -464,6 +526,11 @@ func Register(collectors ...metrics.StableCollector) {
|
||||
legacyregistry.MustRegister(DevicePluginAllocationDuration)
|
||||
legacyregistry.MustRegister(RunningContainerCount)
|
||||
legacyregistry.MustRegister(RunningPodCount)
|
||||
legacyregistry.MustRegister(ManagedEphemeralContainers)
|
||||
legacyregistry.MustRegister(StartedPodsTotal)
|
||||
legacyregistry.MustRegister(StartedPodsErrorsTotal)
|
||||
legacyregistry.MustRegister(StartedContainersTotal)
|
||||
legacyregistry.MustRegister(StartedContainersErrorsTotal)
|
||||
legacyregistry.MustRegister(RunPodSandboxDuration)
|
||||
legacyregistry.MustRegister(RunPodSandboxErrors)
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
|
||||
|
Reference in New Issue
Block a user