metrics

package
v1.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 71

Documentation

Index

Constants

View Source
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.

View Source
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"
)

Below are possible values for the extension_point label.

View Source
const (
	// SchedulerSubsystem - subsystem name used by scheduler.
	SchedulerSubsystem = "scheduler"
)

Variables

View Source
var (
	SchedulingAlgorithmLatency = metrics.NewHistogram(
		&metrics.HistogramOpts{
			Subsystem:      SchedulerSubsystem,
			Name:           "scheduling_algorithm_duration_seconds",
			Help:           "Scheduling algorithm latency in seconds",
			Buckets:        metrics.ExponentialBuckets(0.001, 2, 15),
			StabilityLevel: metrics.ALPHA,
		},
	)
	PreemptionVictims = metrics.NewHistogram(
		&metrics.HistogramOpts{
			Subsystem: SchedulerSubsystem,
			Name:      "preemption_victims",
			Help:      "Number of selected preemption victims",

			Buckets:        metrics.ExponentialBuckets(1, 2, 7),
			StabilityLevel: metrics.STABLE,
		})
	PreemptionAttempts = metrics.NewCounter(
		&metrics.CounterOpts{
			Subsystem:      SchedulerSubsystem,
			Name:           "preemption_attempts_total",
			Help:           "Total preemption attempts in the cluster till now",
			StabilityLevel: metrics.STABLE,
		})

	Goroutines = metrics.NewGaugeVec(
		&metrics.GaugeOpts{
			Subsystem:      SchedulerSubsystem,
			Name:           "goroutines",
			Help:           "Number of running goroutines split by the work they do such as binding.",
			StabilityLevel: metrics.ALPHA,
		}, []string{"operation"})

	// PodSchedulingDuration is deprecated as of Kubernetes v1.28, and will be removed
	// in v1.31. Please use PodSchedulingSLIDuration instead.
	PodSchedulingDuration = metrics.NewHistogramVec(
		&metrics.HistogramOpts{
			Subsystem: SchedulerSubsystem,
			Name:      "pod_scheduling_duration_seconds",
			Help:      "E2e latency for a pod being scheduled which may include multiple scheduling attempts.",

			Buckets:           metrics.ExponentialBuckets(0.01, 2, 20),
			StabilityLevel:    metrics.STABLE,
			DeprecatedVersion: "1.29.0",
		},
		[]string{"attempts"})

	PodSchedulingSLIDuration = metrics.NewHistogramVec(
		&metrics.HistogramOpts{
			Subsystem: SchedulerSubsystem,
			Name:      "pod_scheduling_sli_duration_seconds",
			Help:      "E2e latency for a pod being scheduled, from the time the pod enters the scheduling queue an d might involve multiple scheduling attempts.",

			Buckets:        metrics.ExponentialBuckets(0.01, 2, 20),
			StabilityLevel: metrics.BETA,
		},
		[]string{"attempts"})

	PodSchedulingAttempts = metrics.NewHistogram(
		&metrics.HistogramOpts{
			Subsystem:      SchedulerSubsystem,
			Name:           "pod_scheduling_attempts",
			Help:           "Number of attempts to successfully schedule a pod.",
			Buckets:        metrics.ExponentialBuckets(1, 2, 5),
			StabilityLevel: metrics.STABLE,
		})

	FrameworkExtensionPointDuration = metrics.NewHistogramVec(
		&metrics.HistogramOpts{
			Subsystem: SchedulerSubsystem,
			Name:      "framework_extension_point_duration_seconds",
			Help:      "Latency for running all plugins of a specific extension point.",

			Buckets:        metrics.ExponentialBuckets(0.0001, 2, 12),
			StabilityLevel: metrics.STABLE,
		},
		[]string{"extension_point", "status", "profile"})

	PluginExecutionDuration = metrics.NewHistogramVec(
		&metrics.HistogramOpts{
			Subsystem: SchedulerSubsystem,
			Name:      "plugin_execution_duration_seconds",
			Help:      "Duration for running a plugin at a specific extension point.",

			Buckets:        metrics.ExponentialBuckets(0.00001, 1.5, 20),
			StabilityLevel: metrics.ALPHA,
		},
		[]string{"plugin", "extension_point", "status"})

	SchedulerQueueIncomingPods = metrics.NewCounterVec(
		&metrics.CounterOpts{
			Subsystem:      SchedulerSubsystem,
			Name:           "queue_incoming_pods_total",
			Help:           "Number of pods added to scheduling queues by event and queue type.",
			StabilityLevel: metrics.STABLE,
		}, []string{"queue", "event"})

	PermitWaitDuration = metrics.NewHistogramVec(
		&metrics.HistogramOpts{
			Subsystem:      SchedulerSubsystem,
			Name:           "permit_wait_duration_seconds",
			Help:           "Duration of waiting on permit.",
			Buckets:        metrics.ExponentialBuckets(0.001, 2, 15),
			StabilityLevel: metrics.ALPHA,
		},
		[]string{"result"})

	CacheSize = metrics.NewGaugeVec(
		&metrics.GaugeOpts{
			Subsystem:      SchedulerSubsystem,
			Name:           "scheduler_cache_size",
			Help:           "Number of nodes, pods, and assumed (bound) pods in the scheduler cache.",
			StabilityLevel: metrics.ALPHA,
		}, []string{"type"})

	PluginEvaluationTotal = metrics.NewCounterVec(
		&metrics.CounterOpts{
			Subsystem:      SchedulerSubsystem,
			Name:           "plugin_evaluation_total",
			Help:           "Number of attempts to schedule pods by each plugin and the extension point (available only in PreFilter, Filter, PreScore, and Score).",
			StabilityLevel: metrics.ALPHA,
		}, []string{"plugin", "extension_point", "profile"})
)

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

View Source
var (
	ScheduledResult     = "scheduled"
	UnschedulableResult = "unschedulable"
	ErrorResult         = "error"
)

Functions

func ActivePods added in v1.15.0

func ActivePods() metrics.GaugeMetric

ActivePods returns the pending pods metrics with the label active

func BackoffPods added in v1.15.0

func BackoffPods() metrics.GaugeMetric

BackoffPods returns the pending pods metrics with the label backoff

func GatedPods added in v1.26.0

func GatedPods() metrics.GaugeMetric

GatedPods returns the pending pods metrics with the label gated

func GetGather added in v1.17.0

func GetGather() metrics.Gatherer

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

func PodScheduleError added in v1.19.0

func PodScheduleError(profile string, duration float64)

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

func PodScheduled added in v1.19.0

func PodScheduled(profile string, duration float64)

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

func PodUnschedulable added in v1.19.0

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 added in v1.19.0

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 added in v1.11.0

func SinceInSeconds(start time.Time) float64

SinceInSeconds gets the time since the specified start in seconds.

func UnschedulablePods added in v1.15.0

func UnschedulablePods() metrics.GaugeMetric

UnschedulablePods returns the pending pods metrics with the label unschedulable

func UnschedulableReason added in v1.24.0

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

Types

type MetricAsyncRecorder added in v1.27.0

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 added in v1.27.0

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

func (*MetricAsyncRecorder) FlushMetrics added in v1.27.0

func (r *MetricAsyncRecorder) FlushMetrics()

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

func (*MetricAsyncRecorder) ObservePluginDurationAsync added in v1.27.0

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.

type MetricRecorder added in v1.15.0

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

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

type PendingPodsRecorder added in v1.15.0

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

PendingPodsRecorder is an implementation of MetricRecorder

func NewActivePodsRecorder added in v1.15.0

func NewActivePodsRecorder() *PendingPodsRecorder

NewActivePodsRecorder returns ActivePods in a Prometheus metric fashion

func NewBackoffPodsRecorder added in v1.15.0

func NewBackoffPodsRecorder() *PendingPodsRecorder

NewBackoffPodsRecorder returns BackoffPods in a Prometheus metric fashion

func NewGatedPodsRecorder added in v1.26.0

func NewGatedPodsRecorder() *PendingPodsRecorder

NewGatedPodsRecorder returns GatedPods in a Prometheus metric fashion

func NewUnschedulablePodsRecorder added in v1.15.0

func NewUnschedulablePodsRecorder() *PendingPodsRecorder

NewUnschedulablePodsRecorder returns UnschedulablePods in a Prometheus metric fashion

func (*PendingPodsRecorder) Clear added in v1.15.0

func (r *PendingPodsRecorder) Clear()

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

func (*PendingPodsRecorder) Dec added in v1.15.0

func (r *PendingPodsRecorder) Dec()

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

func (*PendingPodsRecorder) Inc added in v1.15.0

func (r *PendingPodsRecorder) Inc()

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

Directories

Path Synopsis
Package 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.
Package 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL