kubernetes/kops · error
error enabling metrics collection for AutoscalingGroup: %v
Error message
error enabling metrics collection for AutoscalingGroup: %v
What it means
RenderAWS failed to call EnableMetricsCollection on the newly created AutoScalingGroup: the ASG itself was created, but detailed monitoring could not be enabled — typically an IAM permission (autoscaling:EnableMetricsCollection), throttling, or an invalid metrics/granularity combination.
Source
Thrown at upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go:440
// @step: attempt to create the autoscaling group for us
if _, err := t.Cloud.Autoscaling().CreateAutoScalingGroup(ctx, request); err != nil {
code := awsup.AWSErrorCode(err)
message := awsup.AWSErrorMessage(err)
if code == "ValidationError" && strings.Contains(message, "Invalid IAM Instance Profile name") {
klog.V(4).Infof("error creating AutoscalingGroup: %s", message)
return fi.NewTryAgainLaterError("waiting for the IAM Instance Profile to be propagated")
}
return fmt.Errorf("error creating AutoScalingGroup: %s", message)
}
// @step: attempt to enable the metrics for us
if _, err := t.Cloud.Autoscaling().EnableMetricsCollection(ctx, &autoscaling.EnableMetricsCollectionInput{
AutoScalingGroupName: e.Name,
Granularity: e.Granularity,
Metrics: e.Metrics,
}); err != nil {
return fmt.Errorf("error enabling metrics collection for AutoscalingGroup: %v", err)
}
if len(*e.SuspendProcesses) > 0 {
processQuery := &autoscaling.SuspendProcessesInput{}
processQuery.AutoScalingGroupName = e.Name
processQuery.ScalingProcesses = *e.SuspendProcesses
if _, err := t.Cloud.Autoscaling().SuspendProcesses(ctx, processQuery); err != nil {
return fmt.Errorf("error suspending processes: %v", err)
}
}
} else {
// @logic: else we have found a autoscaling group and we need to evaluate the difference
request := &autoscaling.UpdateAutoScalingGroupInput{
AutoScalingGroupName: e.Name,
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Check `metrics:` and granularity in the instance group spec; remove unsupported metric names (valid: e.g. GroupMinSize, GroupMaxSize, GroupDesiredCapacity...)
- Ensure granularity is '1Minute'
- Re-run `kops update cluster` — the ASG exists, only metrics enablement failed
- Verify IAM permissions for autoscaling:EnableMetricsCollection
Example fix
// before metrics: [GroupMinSize, GroupTotalInstances, BogusMetric] // after metrics: [GroupMinSize, GroupMaxSize, GroupDesiredCapacity, GroupInServiceInstances]
Defensive patterns
Strategy: validation
Validate before calling
valid := map[string]bool{"GroupMinSize":true,"GroupMaxSize":true,"GroupDesiredCapacity":true,"GroupInServiceInstances":true,"GroupPendingInstances":true,"GroupStandbyInstances":true,"GroupTerminatingInstances":true,"GroupTotalInstances":true}
for _, m := range ig.Spec.Metrics {
if !valid[m] { return fmt.Errorf("unsupported ASG metric %q", m) }
}
if ig.Spec.Granularity != "" && ig.Spec.Granularity != "1Minute" { return errors.New("granularity must be 1Minute") } Prevention
- Only use documented ASG metric names in `metrics:`
- Keep granularity at 1Minute
- Ensure the apply IAM policy includes autoscaling:EnableMetricsCollection
When it happens
Trigger: CreateAutoScalingGroup succeeded, but the follow-up EnableMetricsCollection input is rejected — e.g. invalid Granularity (must be '1Minute'), invalid metric names, or transient AWS errors.
Common situations: Custom metrics list containing a misspelled/unsupported metric, or empty/incorrect granularity after editing instance group spec `metrics:` fields.
Related errors
- DIGITALOCEAN_ACCESS_TOKEN is required
- the image for the hook exec action not set
- IP version is incorrect
- ErrAlreadyExists
- DIGITALOCEAN_ACCESS_TOKEN is required
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/0238a6e96f81847b.
Report an issue: GitHub.