Skip to content

Commit

Permalink
fix: rename the metrics for proposed resource requests
Browse files Browse the repository at this point in the history
  • Loading branch information
sanposhiho committed Oct 2, 2023
1 parent afc3d0f commit f5d25f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
14 changes: 10 additions & 4 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -33,6 +38,7 @@ func init() {
ProposedHPATargetUtilization,
ProposedHPAMinReplicass,
ProposedHPAMaxReplicass,
ProposedResourceRequest,
ProposedCPURequest,
ProposedMemoryRequest,
)
}
7 changes: 6 additions & 1 deletion pkg/vpa/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit f5d25f7

Please sign in to comment.