Skip to content

Commit

Permalink
add: applied_hpa_utilization_target metric (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanposhiho authored Oct 12, 2023
1 parent 3232c2e commit 60bee81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/hpa/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -35,6 +40,7 @@ var (
func init() {
//Register metrics with prometheus
metrics.Registry.MustRegister(
AppliedHPATargetUtilization,
ProposedHPATargetUtilization,
ProposedHPAMinReplicass,
ProposedHPAMaxReplicass,
Expand Down

0 comments on commit 60bee81

Please sign in to comment.