kubernetesk8s.io/kubernetes/pkg/scheduler/metrics Index | Files | Directories

package metrics

import "k8s.io/kubernetes/pkg/scheduler/metrics"

Index

Constants

const (
	// PrioritizingExtender - prioritizing extender work/operation label value.
	PrioritizingExtender = "prioritizing_extender"
	// Binding - binding work/operation label value.
	Binding = "binding"
)

Below are possible values for the work and operation label.

const (
	GoroutineResultSuccess = "success"
	GoroutineResultError   = "error"
)
const (
	PreFilter                   = "PreFilter"
	Filter                      = "Filter"
	PreFilterExtensionAddPod    = "PreFilterExtensionAddPod"
	PreFilterExtensionRemovePod = "PreFilterExtensionRemovePod"
	PostFilter                  = "PostFilter"
	PreScore                    = "PreScore"
	Score                       = "Score"
	ScoreExtensionNormalize     = "ScoreExtensionNormalize"
	PreBind                     = "PreBind"
	Bind                        = "Bind"
	PostBind                    = "PostBind"
	Reserve                     = "Reserve"
	Unreserve                   = "Unreserve"
	Permit                      = "Permit"
)
const (
	QueueingHintResultQueue     = "Queue"
	QueueingHintResultQueueSkip = "QueueSkip"
	QueueingHintResultError     = "Error"
)
const (
	PodPoppedInFlightEvent = "PodPopped"
)
const (
	// SchedulerSubsystem - subsystem name used by scheduler.
	SchedulerSubsystem = "scheduler"
)

Variables

var (
	EventHandlingLatency *metrics.HistogramVec

	SchedulingAlgorithmLatency *metrics.Histogram
	PreemptionVictims          *metrics.Histogram
	PreemptionAttempts         *metrics.Counter

	InFlightEvents *metrics.GaugeVec
	Goroutines     *metrics.GaugeVec

	PodSchedulingSLIDuration        *metrics.HistogramVec
	PodSchedulingAttempts           *metrics.Histogram
	FrameworkExtensionPointDuration *metrics.HistogramVec
	PluginExecutionDuration         *metrics.HistogramVec

	PermitWaitDuration *metrics.HistogramVec
	CacheSize          *metrics.GaugeVec
	// Deprecated: SchedulerCacheSize is deprecated,
	// and will be removed at v1.34. Please use CacheSize instead.
	SchedulerCacheSize *metrics.GaugeVec

	PluginEvaluationTotal *metrics.CounterVec

	SchedulerQueueIncomingPods *metrics.CounterVec

	// The below two are only available when the async-preemption feature gate is enabled.
	PreemptionGoroutinesDuration       *metrics.HistogramVec
	PreemptionGoroutinesExecutionTotal *metrics.CounterVec
)

All the histogram based metrics have 1ms as size for the smallest bucket.

var (
	ScheduledResult     = "scheduled"
	UnschedulableResult = "unschedulable"
	ErrorResult         = "error"
)
var ExtentionPoints = []string{
	PreFilter,
	Filter,
	PreFilterExtensionAddPod,
	PreFilterExtensionRemovePod,
	PostFilter,
	PreScore,
	Score,
	ScoreExtensionNormalize,
	PreBind,
	Bind,
	PostBind,
	Reserve,
	Unreserve,
	Permit,
}

ExtentionPoints is a list of possible values for the extension_point label.

Functions

func ActivePods

func ActivePods() metrics.GaugeMetric

ActivePods returns the pending pods metrics with the label active

func BackoffPods

func BackoffPods() metrics.GaugeMetric

BackoffPods returns the pending pods metrics with the label backoff

func GatedPods

func GatedPods() metrics.GaugeMetric

GatedPods returns the pending pods metrics with the label gated

func GetGather

func GetGather() metrics.Gatherer

GetGather returns the gatherer. It used by test case outside current package.

func InitMetrics

func InitMetrics()

func PodScheduleError

func PodScheduleError(profile string, duration float64)

PodScheduleError can records a scheduling attempt that had an error and the duration since `start`.

func PodScheduled

func PodScheduled(profile string, duration float64)

PodScheduled can records a successful scheduling attempt and the duration since `start`.

func PodUnschedulable

func PodUnschedulable(profile string, duration float64)

PodUnschedulable can records a scheduling attempt for an unschedulable pod and the duration since `start`.

func Register

func Register()

Register all metrics.

func RegisterMetrics

func RegisterMetrics(extraMetrics ...metrics.Registerable)

RegisterMetrics registers a list of metrics. This function is exported because it is intended to be used by out-of-tree plugins to register their custom metrics.

func SinceInSeconds

func SinceInSeconds(start time.Time) float64

SinceInSeconds gets the time since the specified start in seconds.

func UnschedulablePods

func UnschedulablePods() metrics.GaugeMetric

UnschedulablePods returns the pending pods metrics with the label unschedulable

func UnschedulableReason

func UnschedulableReason(plugin string, profile string) metrics.GaugeMetric

Types

type MetricAsyncRecorder

type MetricAsyncRecorder struct {

	// IsStoppedCh indicates whether the goroutine is stopped. It's used in tests only to make sure
	// the metric flushing goroutine is stopped so that tests can collect metrics for verification.
	IsStoppedCh chan struct{}
	// contains filtered or unexported fields
}

MetricAsyncRecorder records metric in a separate goroutine to avoid overhead in the critical path.

func NewMetricsAsyncRecorder

func NewMetricsAsyncRecorder(bufferSize int, interval time.Duration, stopCh <-chan struct{}) *MetricAsyncRecorder

func (*MetricAsyncRecorder) FlushMetrics

func (r *MetricAsyncRecorder) FlushMetrics()

FlushMetrics tries to clean up the bufferCh by reading at most bufferSize metrics.

func (*MetricAsyncRecorder) ObserveInFlightEventsAsync

func (r *MetricAsyncRecorder) ObserveInFlightEventsAsync(eventLabel string, valueToAdd float64, forceFlush bool)

ObserveInFlightEventsAsync observes the in_flight_events metric.

Note that this function is not goroutine-safe; we don't lock the map deliberately for the performance reason and we assume the queue (i.e., the caller) takes lock before updating the in-flight events.

func (*MetricAsyncRecorder) ObservePluginDurationAsync

func (r *MetricAsyncRecorder) ObservePluginDurationAsync(extensionPoint, pluginName, status string, value float64)

ObservePluginDurationAsync observes the plugin_execution_duration_seconds metric. The metric will be flushed to Prometheus asynchronously.

func (*MetricAsyncRecorder) ObserveQueueingHintDurationAsync

func (r *MetricAsyncRecorder) ObserveQueueingHintDurationAsync(pluginName, event, hint string, value float64)

ObserveQueueingHintDurationAsync observes the queueing_hint_execution_duration_seconds metric. The metric will be flushed to Prometheus asynchronously.

type MetricRecorder

type MetricRecorder interface {
	Inc()
	Dec()
	Clear()
}

MetricRecorder represents a metric recorder which takes action when the metric Inc(), Dec() and Clear()

type PendingPodsRecorder

type PendingPodsRecorder struct {
	// contains filtered or unexported fields
}

PendingPodsRecorder is an implementation of MetricRecorder

func NewActivePodsRecorder

func NewActivePodsRecorder() *PendingPodsRecorder

NewActivePodsRecorder returns ActivePods in a Prometheus metric fashion

func NewBackoffPodsRecorder

func NewBackoffPodsRecorder() *PendingPodsRecorder

NewBackoffPodsRecorder returns BackoffPods in a Prometheus metric fashion

func NewGatedPodsRecorder

func NewGatedPodsRecorder() *PendingPodsRecorder

NewGatedPodsRecorder returns GatedPods in a Prometheus metric fashion

func NewUnschedulablePodsRecorder

func NewUnschedulablePodsRecorder() *PendingPodsRecorder

NewUnschedulablePodsRecorder returns UnschedulablePods in a Prometheus metric fashion

func (*PendingPodsRecorder) Clear

func (r *PendingPodsRecorder) Clear()

Clear set a metric counter to 0, in an atomic way

func (*PendingPodsRecorder) Dec

func (r *PendingPodsRecorder) Dec()

Dec decreases a metric counter by 1, in an atomic way

func (*PendingPodsRecorder) Inc

func (r *PendingPodsRecorder) Inc()

Inc increases a metric counter by 1, in an atomic way

Source Files

metric_recorder.go metrics.go profile_metrics.go

Directories

PathSynopsis
pkg/scheduler/metrics/resourcesPackage resources provides a metrics collector that reports the resource consumption (requests and limits) of the pods in the cluster as the scheduler and kubelet would interpret it.
Version
v1.33.0 (latest)
Published
Apr 23, 2025
Platform
linux/amd64
Imports
7 packages
Last checked
3 hours ago

Tools for package owners.