From 9017e62f8ff652ad13a0b0bc46738dd5e39648f2 Mon Sep 17 00:00:00 2001 From: randytqwjp Date: Fri, 27 Sep 2024 12:27:27 +0900 Subject: [PATCH] add label to net hpa metric --- pkg/hpa/service.go | 4 ++-- pkg/metrics/metrics.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/hpa/service.go b/pkg/hpa/service.go index 4c986ec..444f98d 100644 --- a/pkg/hpa/service.go +++ b/pkg/hpa/service.go @@ -454,8 +454,8 @@ func (c *Service) ChangeHPAFromTortoiseRecommendation(tortoise *autoscalingv1bet if netChangeMaxReplicas < 0 || netChangeMinReplicas > 0 { metrics.DecreaseApplyCounter.WithLabelValues(tortoise.Name, tortoise.Namespace).Add(1) } - metrics.NetHPAMinReplicas.WithLabelValues(tortoise.Name, tortoise.Namespace, hpa.Name).Set(netChangeMinReplicas) - metrics.NetHPAMaxReplicas.WithLabelValues(tortoise.Name, tortoise.Namespace, hpa.Name).Set(netChangeMaxReplicas) + metrics.NetHPAMinReplicas.WithLabelValues(tortoise.Name, tortoise.Namespace, hpa.Name, tortoise.Spec.TargetRefs.ScaleTargetRef.Name).Set(netChangeMinReplicas) + metrics.NetHPAMaxReplicas.WithLabelValues(tortoise.Name, tortoise.Namespace, hpa.Name, tortoise.Spec.TargetRefs.ScaleTargetRef.Name).Set(netChangeMaxReplicas) metrics.AppliedHPAMinReplicas.WithLabelValues(tortoise.Name, tortoise.Namespace, hpa.Name).Set(float64(*hpa.Spec.MinReplicas)) metrics.AppliedHPAMaxReplicas.WithLabelValues(tortoise.Name, tortoise.Namespace, hpa.Name).Set(float64(hpa.Spec.MaxReplicas)) } diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index b981c3f..f29fa89 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -59,12 +59,12 @@ var ( NetHPAMinReplicas = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "net_hpa_minreplicas", Help: "net hpa minReplicas that tortoises actually applys to hpa", - }, []string{"tortoise_name", "namespace", "hpa_name"}) + }, []string{"tortoise_name", "namespace", "hpa_name", "kube_deployment"}) NetHPAMaxReplicas = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "net_hpa_maxreplicas", Help: "net hpa maxReplicas that tortoises actually applys to hpa", - }, []string{"tortoise_name", "namespace", "hpa_name"}) + }, []string{"tortoise_name", "namespace", "hpa_name", "kube_deployment"}) NetCPURequest = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "net_cpu_request",