From 60bee818cc6fff7dc6e1efec7c01d5f981a550dc Mon Sep 17 00:00:00 2001 From: Kensei Nakada Date: Thu, 12 Oct 2023 17:27:52 +0900 Subject: [PATCH] add: applied_hpa_utilization_target metric (#179) --- pkg/hpa/service.go | 4 ++++ pkg/metrics/metrics.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/pkg/hpa/service.go b/pkg/hpa/service.go index c6c002a2..7c22499a 100644 --- a/pkg/hpa/service.go +++ b/pkg/hpa/service.go @@ -368,6 +368,10 @@ func (c *Service) ChangeHPAFromTortoiseRecommendation(tortoise *autoscalingv1bet continue } + if allowed && tortoise.Spec.UpdateMode != autoscalingv1beta2.UpdateModeOff { + metrics.AppliedHPATargetUtilization.WithLabelValues(tortoise.Name, tortoise.Namespace, t.ContainerName, resourcename.String(), hpa.Name).Set(float64(proposedTarget)) + } + if err := c.updateHPATargetValue(hpa, t.ContainerName, resourcename, proposedTarget); err != nil { return nil, tortoise, fmt.Errorf("update HPA from the recommendation from tortoise") } diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 611b8629..eea02e09 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -6,6 +6,11 @@ import ( ) var ( + AppliedHPATargetUtilization = prometheus.NewGaugeVec(prometheus.GaugeOpts{ + Name: "applied_hpa_utilization_target", + Help: "hpa utilization target values that tortoises actually applys to hpa", + }, []string{"tortoise_name", "namespace", "container_name", "resource_name", "hpa_name"}) + ProposedHPATargetUtilization = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "proposed_hpa_utilization_target", Help: "recommended hpa utilization target values that tortoises propose", @@ -35,6 +40,7 @@ var ( func init() { //Register metrics with prometheus metrics.Registry.MustRegister( + AppliedHPATargetUtilization, ProposedHPATargetUtilization, ProposedHPAMinReplicass, ProposedHPAMaxReplicass,