Skip to content

Commit

Permalink
Track type of node group created/deleted in auto-provisioned group me…
Browse files Browse the repository at this point in the history
…trics.
  • Loading branch information
dsafdsa1 committed Mar 14, 2024
1 parent a3c8978 commit b6e38f7
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions cluster-autoscaler/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package metrics

import (
"fmt"
"strconv"
"time"

"k8s.io/autoscaler/cluster-autoscaler/simulator"
Expand Down Expand Up @@ -390,20 +391,22 @@ var (
},
)

nodeGroupCreationCount = k8smetrics.NewCounter(
nodeGroupCreationCount = k8smetrics.NewCounterVec(
&k8smetrics.CounterOpts{
Namespace: caNamespace,
Name: "created_node_groups_total",
Help: "Number of node groups created by Node Autoprovisioning.",
},
[]string{"group_type"},
)

nodeGroupDeletionCount = k8smetrics.NewCounter(
nodeGroupDeletionCount = k8smetrics.NewCounterVec(
&k8smetrics.CounterOpts{
Namespace: caNamespace,
Name: "deleted_node_groups_total",
Help: "Number of node groups deleted by Node Autoprovisioning.",
},
[]string{"group_type"},
)

nodeTaintsCount = k8smetrics.NewGaugeVec(
Expand Down Expand Up @@ -643,12 +646,27 @@ func UpdateNapEnabled(enabled bool) {

// RegisterNodeGroupCreation registers node group creation
func RegisterNodeGroupCreation() {
nodeGroupCreationCount.Add(1.0)
RegisterNodeGroupCreationWithLabelValues("")
}

// RegisterQueuedProvisioningNodeGroupCreation registers node group creation with the provided labels
func RegisterNodeGroupCreationWithLabelValues(groupType string) {
nodeGroupCreationCount.WithLabelValues(groupType).Add(1.0)
}

// RegisterNodeGroupDeletion registers node group deletion
func RegisterNodeGroupDeletion() {
nodeGroupDeletionCount.Add(1.0)
RegisterNodeGroupDeletionWithLabelValues("")
}

// RegisterNodeGroupDeletion registers node group deletion with the provided labels
func RegisterNodeGroupDeletionWithLabelValues(groupType string) {
nodeGroupDeletionCount.WithLabelValues(groupType).Add(1.0)
}

// RegisterQueuedProvisioningNodeGroupDeletion registers queued provisioning node group deletion
func RegisterQueuedProvisioningNodeGroupDeletion() {
nodeGroupDeletionCount.WithLabelValues(strconv.FormatBool(true)).Add(1.0)
}

// UpdateScaleDownInCooldown registers if the cluster autoscaler
Expand Down

0 comments on commit b6e38f7

Please sign in to comment.