Skip to content

Commit

Permalink
add(metrics): add controller_name and controller_kind to metrics label (
Browse files Browse the repository at this point in the history
  • Loading branch information
sanposhiho authored Oct 3, 2023
1 parent 885061e commit a17e19f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/vpa/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a17e19f

Please sign in to comment.