{"record":{"id":"0238a6e96f81847b","repo":"kubernetes/kops","slug":"error-enabling-metrics-collection-for-autoscalingg","errorCode":null,"errorMessage":"error enabling metrics collection for AutoscalingGroup: %v","messagePattern":"error enabling metrics collection for AutoscalingGroup: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go","lineNumber":440,"sourceCode":"\n\t\t// @step: attempt to create the autoscaling group for us\n\t\tif _, err := t.Cloud.Autoscaling().CreateAutoScalingGroup(ctx, request); err != nil {\n\t\t\tcode := awsup.AWSErrorCode(err)\n\t\t\tmessage := awsup.AWSErrorMessage(err)\n\t\t\tif code == \"ValidationError\" && strings.Contains(message, \"Invalid IAM Instance Profile name\") {\n\t\t\t\tklog.V(4).Infof(\"error creating AutoscalingGroup: %s\", message)\n\t\t\t\treturn fi.NewTryAgainLaterError(\"waiting for the IAM Instance Profile to be propagated\")\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"error creating AutoScalingGroup: %s\", message)\n\t\t}\n\n\t\t// @step: attempt to enable the metrics for us\n\t\tif _, err := t.Cloud.Autoscaling().EnableMetricsCollection(ctx, &autoscaling.EnableMetricsCollectionInput{\n\t\t\tAutoScalingGroupName: e.Name,\n\t\t\tGranularity:          e.Granularity,\n\t\t\tMetrics:              e.Metrics,\n\t\t}); err != nil {\n\t\t\treturn fmt.Errorf(\"error enabling metrics collection for AutoscalingGroup: %v\", err)\n\t\t}\n\n\t\tif len(*e.SuspendProcesses) > 0 {\n\t\t\tprocessQuery := &autoscaling.SuspendProcessesInput{}\n\t\t\tprocessQuery.AutoScalingGroupName = e.Name\n\t\t\tprocessQuery.ScalingProcesses = *e.SuspendProcesses\n\n\t\t\tif _, err := t.Cloud.Autoscaling().SuspendProcesses(ctx, processQuery); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error suspending processes: %v\", err)\n\t\t\t}\n\t\t}\n\n\t} else {\n\t\t// @logic: else we have found a autoscaling group and we need to evaluate the difference\n\t\trequest := &autoscaling.UpdateAutoScalingGroupInput{\n\t\t\tAutoScalingGroupName: e.Name,\n\t\t}\n","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go#L422-L458","documentation":"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.","triggerScenarios":"CreateAutoScalingGroup succeeded, but the follow-up EnableMetricsCollection input is rejected — e.g. invalid Granularity (must be '1Minute'), invalid metric names, or transient AWS errors.","commonSituations":"Custom metrics list containing a misspelled/unsupported metric, or empty/incorrect granularity after editing instance group spec `metrics:` fields.","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"],"exampleFix":"// before\nmetrics: [GroupMinSize, GroupTotalInstances, BogusMetric]\n// after\nmetrics: [GroupMinSize, GroupMaxSize, GroupDesiredCapacity, GroupInServiceInstances]","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"GroupMinSize\":true,\"GroupMaxSize\":true,\"GroupDesiredCapacity\":true,\"GroupInServiceInstances\":true,\"GroupPendingInstances\":true,\"GroupStandbyInstances\":true,\"GroupTerminatingInstances\":true,\"GroupTotalInstances\":true}\nfor _, m := range ig.Spec.Metrics {\n  if !valid[m] { return fmt.Errorf(\"unsupported ASG metric %q\", m) }\n}\nif ig.Spec.Granularity != \"\" && ig.Spec.Granularity != \"1Minute\" { return errors.New(\"granularity must be 1Minute\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use documented ASG metric names in `metrics:`","Keep granularity at 1Minute","Ensure the apply IAM policy includes autoscaling:EnableMetricsCollection"],"tags":["aws","autoscaling","cloudwatch","metrics"],"backgroundTag":"aws-api-call-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}