From 4f7717842ca698ce0f5fca1fe2911e515c32099e Mon Sep 17 00:00:00 2001 From: Kensei Nakada Date: Sat, 4 Feb 2023 07:21:03 +0000 Subject: [PATCH 1/2] feature(scheduler): implement plugin_evaluation_total metric --- pkg/scheduler/framework/runtime/framework.go | 1 + pkg/scheduler/metrics/metrics.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/pkg/scheduler/framework/runtime/framework.go b/pkg/scheduler/framework/runtime/framework.go index 1dbce09ff11..b1275e62775 100644 --- a/pkg/scheduler/framework/runtime/framework.go +++ b/pkg/scheduler/framework/runtime/framework.go @@ -734,6 +734,7 @@ func (f *frameworkImpl) RunFilterPlugins( if state.SkipFilterPlugins.Has(pl.Name()) { continue } + metrics.PluginEvaluationTotal.WithLabelValues(pl.Name(), Filter).Inc() if status := f.runFilterPlugin(ctx, pl, state, pod, nodeInfo); !status.IsSuccess() { if !status.IsUnschedulable() { // Filter plugins are not supposed to return any status other than diff --git a/pkg/scheduler/metrics/metrics.go b/pkg/scheduler/metrics/metrics.go index 335cba29396..f5c3eda1ce9 100644 --- a/pkg/scheduler/metrics/metrics.go +++ b/pkg/scheduler/metrics/metrics.go @@ -189,6 +189,14 @@ var ( StabilityLevel: metrics.ALPHA, }, []string{"plugin", "profile"}) + 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 (only Filter is supported now.).", + StabilityLevel: metrics.ALPHA, + }, []string{"plugin", "extension_point"}) + metricsList = []metrics.Registerable{ scheduleAttempts, e2eSchedulingLatency, @@ -207,6 +215,7 @@ var ( PermitWaitDuration, CacheSize, unschedulableReasons, + PluginEvaluationTotal, } ) From 608f4808ffa352dfd72fa5d88dbe769f60ed0c24 Mon Sep 17 00:00:00 2001 From: Kensei Nakada Date: Mon, 6 Mar 2023 00:48:30 +0000 Subject: [PATCH 2/2] support PreFilter as well --- pkg/scheduler/framework/runtime/framework.go | 3 ++- pkg/scheduler/metrics/metrics.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/scheduler/framework/runtime/framework.go b/pkg/scheduler/framework/runtime/framework.go index b1275e62775..fc0d10f822a 100644 --- a/pkg/scheduler/framework/runtime/framework.go +++ b/pkg/scheduler/framework/runtime/framework.go @@ -617,6 +617,7 @@ func (f *frameworkImpl) RunPreFilterPlugins(ctx context.Context, state *framewor skipPlugins.Insert(pl.Name()) continue } + metrics.PluginEvaluationTotal.WithLabelValues(pl.Name(), preFilter, f.profileName).Inc() if !s.IsSuccess() { s.SetFailedPlugin(pl.Name()) if s.IsUnschedulable() { @@ -734,7 +735,7 @@ func (f *frameworkImpl) RunFilterPlugins( if state.SkipFilterPlugins.Has(pl.Name()) { continue } - metrics.PluginEvaluationTotal.WithLabelValues(pl.Name(), Filter).Inc() + metrics.PluginEvaluationTotal.WithLabelValues(pl.Name(), Filter, f.profileName).Inc() if status := f.runFilterPlugin(ctx, pl, state, pod, nodeInfo); !status.IsSuccess() { if !status.IsUnschedulable() { // Filter plugins are not supposed to return any status other than diff --git a/pkg/scheduler/metrics/metrics.go b/pkg/scheduler/metrics/metrics.go index f5c3eda1ce9..414d0d4d779 100644 --- a/pkg/scheduler/metrics/metrics.go +++ b/pkg/scheduler/metrics/metrics.go @@ -193,9 +193,9 @@ var ( &metrics.CounterOpts{ Subsystem: SchedulerSubsystem, Name: "plugin_evaluation_total", - Help: "Number of attempts to schedule pods by each plugin and the extension point (only Filter is supported now.).", + Help: "Number of attempts to schedule pods by each plugin and the extension point (available only in PreFilter and Filter.).", StabilityLevel: metrics.ALPHA, - }, []string{"plugin", "extension_point"}) + }, []string{"plugin", "extension_point", "profile"}) metricsList = []metrics.Registerable{ scheduleAttempts,