Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛(metrics) Initialize metrics for autoscaler errors, scale events, and pod evictions #7449

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading