Skip to content

Commit

Permalink
🐛(metrics) Initialize metrics for autoscaler errors, scale events, an…
Browse files Browse the repository at this point in the history
…d pod evictions

- Set initial count to zero for various autoscaler error types (e.g., CloudProviderError, ApiCallError)
- Define failed scale-up reasons and initialize metrics (e.g., CloudProviderError, APIError)
- Initialize pod eviction result counters for success and failure cases
- Initialize skipped scale events for CPU and memory resource limits in both scale-up and scale-down directions

Signed-off-by: Thiha Min Thant <thihaminthant20@gmail.com>
  • Loading branch information
thiha-min-thant committed Nov 2, 2024
1 parent d06fe04 commit ffd57af
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@ func buildAutoscaler(context ctx.Context, debuggingSnapshotter debuggingsnapshot
metrics.UpdateCPULimitsCores(autoscalingOptions.MinCoresTotal, autoscalingOptions.MaxCoresTotal)
metrics.UpdateMemoryLimitsBytes(autoscalingOptions.MinMemoryTotal, autoscalingOptions.MaxMemoryTotal)

// Initialize metrics.
metrics.InitMetrics()

// Create autoscaler.
autoscaler, err := core.NewAutoscaler(opts, informerFactory)
if err != nil {
Expand Down
22 changes: 22 additions & 0 deletions cluster-autoscaler/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,28 @@ func RegisterAll(emitPerNodeGroupMetrics bool) {
}
}

// InitMetrics initializes all metrics
func InitMetrics() {
for _, errorType := range []errors.AutoscalerErrorType{errors.CloudProviderError, errors.ApiCallError, errors.InternalError, errors.TransientError, errors.ConfigurationError, errors.NodeGroupDoesNotExistError, errors.UnexpectedScaleDownStateError} {
errorsCount.WithLabelValues(string(errorType)).Add(0)
}

for _, reason := range []FailedScaleUpReason{CloudProviderError, APIError, Timeout} {
scaleDownCount.WithLabelValues(string(reason)).Add(0)
failedScaleUpCount.WithLabelValues(string(reason)).Add(0)
}

for _, result := range []PodEvictionResult{PodEvictionSucceed, PodEvictionFailed} {
evictionsCount.WithLabelValues(string(result)).Add(0)
}

skippedScaleEventsCount.WithLabelValues(DirectionScaleDown, CpuResourceLimit).Add(0)
skippedScaleEventsCount.WithLabelValues(DirectionScaleDown, MemoryResourceLimit).Add(0)
skippedScaleEventsCount.WithLabelValues(DirectionScaleUp, CpuResourceLimit).Add(0)
skippedScaleEventsCount.WithLabelValues(DirectionScaleUp, MemoryResourceLimit).Add(0)

}

// UpdateDurationFromStart records the duration of the step identified by the
// label using start time
func UpdateDurationFromStart(label FunctionLabel, start time.Time) {
Expand Down

0 comments on commit ffd57af

Please sign in to comment.