From cffaf8b27775a6bf4247a62232f538b9972d4f40 Mon Sep 17 00:00:00 2001 From: Kensei Nakada Date: Tue, 3 Oct 2023 14:38:30 +0900 Subject: [PATCH] add(metrics): add controller_name and controller_kind to metrics label --- pkg/metrics/metrics.go | 4 ++-- pkg/vpa/service.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 8fb2d0d9..359453d0 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -24,12 +24,12 @@ var ( ProposedCPURequest = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "proposed_cpu_request", Help: "recommended cpu request (millicore) that tortoises propose", - }, []string{"tortoise_name", "namespace", "container_name"}) + }, []string{"tortoise_name", "namespace", "container_name", "controller_name", "controller_kind"}) ProposedMemoryRequest = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "proposed_memory_request", Help: "recommended memory request (millibyte) that tortoises propose", - }, []string{"tortoise_name", "namespace", "container_name"}) + }, []string{"tortoise_name", "namespace", "container_name", "controller_name", "controller_kind"}) ) func init() { diff --git a/pkg/vpa/service.go b/pkg/vpa/service.go index 3d20070d..e5488971 100644 --- a/pkg/vpa/service.go +++ b/pkg/vpa/service.go @@ -209,10 +209,10 @@ func (c *Service) UpdateVPAFromTortoiseRecommendation(ctx context.Context, torto if !metricsRecorded { for resourcename, value := range r.RecommendedResource { if resourcename == corev1.ResourceCPU { - metrics.ProposedCPURequest.WithLabelValues(tortoise.Name, tortoise.Namespace, r.ContainerName).Set(float64(value.MilliValue())) + metrics.ProposedCPURequest.WithLabelValues(tortoise.Name, tortoise.Namespace, r.ContainerName, tortoise.Spec.TargetRefs.DeploymentName, "Deployment").Set(float64(value.MilliValue())) } if resourcename == corev1.ResourceMemory { - metrics.ProposedMemoryRequest.WithLabelValues(tortoise.Name, tortoise.Namespace, r.ContainerName).Set(float64(value.MilliValue())) + metrics.ProposedMemoryRequest.WithLabelValues(tortoise.Name, tortoise.Namespace, r.ContainerName, tortoise.Spec.TargetRefs.DeploymentName, "Deployment").Set(float64(value.MilliValue())) } } metricsRecorded = true