Open
Description
Describe the issue
In the linked docs, we can see that we need at least one StepAdjustment
:
StepAdjustments
A set of adjustments that enable you to scale based on the size of the alarm breach.
At least one step adjustment is required if you are adding a new step scaling policy configuration.
Type: Array of StepAdjustment objects
Required: No
As well, the documentation (in python):
response = client.put_scaling_policy(
PolicyName="HasBacklogWithoutCapacity-ScalingPolicy",
ServiceNamespace="sagemaker", # The namespace of the service that provides the resource.
ResourceId=resource_id, # Endpoint name
ScalableDimension="sagemaker:variant:DesiredInstanceCount", # SageMaker supports only Instance Count
PolicyType="StepScaling", # 'StepScaling' or 'TargetTrackingScaling'
StepScalingPolicyConfiguration={
"AdjustmentType": "ChangeInCapacity", # Specifies whether the ScalingAdjustment value in the StepAdjustment property is an absolute number or a percentage of the current capacity.
"MetricAggregationType": "Average", # The aggregation type for the CloudWatch metrics.
"Cooldown": 300, # The amount of time, in seconds, to wait for a previous scaling activity to take effect.
"StepAdjustments": # A set of adjustments that enable you to scale based on the size of the alarm breach.
[
{
"MetricIntervalLowerBound": 0,
"ScalingAdjustment": 1
}
]
},
)
But with the folowing code, I have the error Error: You must supply at least 2 intervals for autoscaling
:
scalableTarget.scaleOnMetric(`${idPrefix}HasBacklogWithoutCapacityScalingPolicy`, {
metric: new cloudwatch.Metric({
metricName: 'HasBacklogWithoutCapacity',
namespace: 'AWS/SageMaker',
label: 'HasBacklogWithoutCapacity',
period: cdk.Duration.minutes(1),
dimensionsMap: {
EndpointName: endpoint.endpointName!
},
statistic: cloudwatch.Stats.AVERAGE
}),
scalingSteps: [{
change: 1,
lower: 0,
}],
adjustmentType: appscaling.AdjustmentType.CHANGE_IN_CAPACITY,
cooldown: cdk.Duration.minutes(5),
});