diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 3c69da05..dcaedf2d 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -21,10 +21,15 @@ var ( Help: "recommended hpa maxReplicas that tortoises propose", }, []string{"tortoise_name", "namespace", "hpa_name"}) - ProposedResourceRequest = prometheus.NewGaugeVec(prometheus.GaugeOpts{ - Name: "proposed_resource_request", + ProposedCPURequest = prometheus.NewGaugeVec(prometheus.GaugeOpts{ + Name: "proposed_cpu_request", Help: "recommended resource request that tortoises propose", - }, []string{"tortoise_name", "namespace", "container_name", "resource_name"}) + }, []string{"tortoise_name", "namespace", "container_name"}) + + ProposedMemoryRequest = prometheus.NewGaugeVec(prometheus.GaugeOpts{ + Name: "proposed_memory_request", + Help: "recommended resource request that tortoises propose", + }, []string{"tortoise_name", "namespace", "container_name"}) ) func init() { @@ -33,6 +38,7 @@ func init() { ProposedHPATargetUtilization, ProposedHPAMinReplicass, ProposedHPAMaxReplicass, - ProposedResourceRequest, + ProposedCPURequest, + ProposedMemoryRequest, ) } diff --git a/pkg/vpa/service.go b/pkg/vpa/service.go index 994c2ffa..fe96ba41 100644 --- a/pkg/vpa/service.go +++ b/pkg/vpa/service.go @@ -208,7 +208,12 @@ func (c *Service) UpdateVPAFromTortoiseRecommendation(ctx context.Context, torto for _, r := range tortoise.Status.Recommendations.Vertical.ContainerResourceRecommendation { if !metricsRecorded { for resourcename, value := range r.RecommendedResource { - metrics.ProposedResourceRequest.WithLabelValues(tortoise.Name, tortoise.Namespace, r.ContainerName, resourcename.String()).Set(float64(value.MilliValue())) + if resourcename == corev1.ResourceCPU { + metrics.ProposedCPURequest.WithLabelValues(tortoise.Name, tortoise.Namespace, r.ContainerName).Set(float64(value.MilliValue())) + } + if resourcename == corev1.ResourceMemory { + metrics.ProposedCPURequest.WithLabelValues(tortoise.Name, tortoise.Namespace, r.ContainerName).Set(float64(value.MilliValue())) + } } metricsRecorded = true }