From 601c5cddf7f0e162a3e6ac060e177848f16a2bc6 Mon Sep 17 00:00:00 2001 From: Mo Zhou Date: Fri, 5 Sep 2025 10:43:09 +0800 Subject: [PATCH] fix(metrics): reset running notebooks metrics before scraping statefulsets --- components/notebook-controller/pkg/metrics/metrics.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/notebook-controller/pkg/metrics/metrics.go b/components/notebook-controller/pkg/metrics/metrics.go index b00fec3fb..23811fcde 100644 --- a/components/notebook-controller/pkg/metrics/metrics.go +++ b/components/notebook-controller/pkg/metrics/metrics.go @@ -80,6 +80,9 @@ func (m *Metrics) Collect(ch chan<- prometheus.Metric) { // scrape gets current running notebook statefulsets. func (m *Metrics) scrape() { + // Reset the current metrics to clear previous data + m.runningNotebooks.Reset() + stsList := &appsv1.StatefulSetList{} err := m.cli.List(context.TODO(), stsList) if err != nil {