2024/11/22 - Auto Scaling - 2 updated api methods
Changes Now, Amazon EC2 Auto Scaling customers can enable target tracking policies to take quicker scaling decisions, enhancing their application performance and EC2 utilization. To get started, specify target tracking to monitor a metric that is available on Amazon CloudWatch at seconds-level interval.
{'ScalingPolicies': {'TargetTrackingConfiguration': {'CustomizedMetricSpecification': {'Metrics': {'MetricStat': {'Period': 'integer'}, 'Period': 'integer'}, 'Period': 'integer'}}}}
Gets information about the scaling policies in the account and Region.
See also: AWS API Documentation
Request Syntax
client.describe_policies( AutoScalingGroupName='string', PolicyNames=[ 'string', ], PolicyTypes=[ 'string', ], NextToken='string', MaxRecords=123 )
string
The name of the Auto Scaling group.
list
The names of one or more policies. If you omit this property, all policies are described. If a group name is provided, the results are limited to that group. If you specify an unknown policy name, it is ignored with no error.
Array Members: Maximum number of 50 items.
(string) --
list
One or more policy types. The valid values are SimpleScaling, StepScaling, TargetTrackingScaling, and PredictiveScaling.
(string) --
string
The token for the next set of items to return. (You received this token from a previous call.)
integer
The maximum number of items to be returned with each call. The default value is 50 and the maximum value is 100.
dict
Response Syntax
{ 'ScalingPolicies': [ { 'AutoScalingGroupName': 'string', 'PolicyName': 'string', 'PolicyARN': 'string', 'PolicyType': 'string', 'AdjustmentType': 'string', 'MinAdjustmentStep': 123, 'MinAdjustmentMagnitude': 123, 'ScalingAdjustment': 123, 'Cooldown': 123, 'StepAdjustments': [ { 'MetricIntervalLowerBound': 123.0, 'MetricIntervalUpperBound': 123.0, 'ScalingAdjustment': 123 }, ], 'MetricAggregationType': 'string', 'EstimatedInstanceWarmup': 123, 'Alarms': [ { 'AlarmName': 'string', 'AlarmARN': 'string' }, ], 'TargetTrackingConfiguration': { 'PredefinedMetricSpecification': { 'PredefinedMetricType': 'ASGAverageCPUUtilization'|'ASGAverageNetworkIn'|'ASGAverageNetworkOut'|'ALBRequestCountPerTarget', 'ResourceLabel': 'string' }, 'CustomizedMetricSpecification': { 'MetricName': 'string', 'Namespace': 'string', 'Dimensions': [ { 'Name': 'string', 'Value': 'string' }, ], 'Statistic': 'Average'|'Minimum'|'Maximum'|'SampleCount'|'Sum', 'Unit': 'string', 'Period': 123, 'Metrics': [ { 'Id': 'string', 'Expression': 'string', 'MetricStat': { 'Metric': { 'Namespace': 'string', 'MetricName': 'string', 'Dimensions': [ { 'Name': 'string', 'Value': 'string' }, ] }, 'Stat': 'string', 'Unit': 'string', 'Period': 123 }, 'Label': 'string', 'Period': 123, 'ReturnData': True|False }, ] }, 'TargetValue': 123.0, 'DisableScaleIn': True|False }, 'Enabled': True|False, 'PredictiveScalingConfiguration': { 'MetricSpecifications': [ { 'TargetValue': 123.0, 'PredefinedMetricPairSpecification': { 'PredefinedMetricType': 'ASGCPUUtilization'|'ASGNetworkIn'|'ASGNetworkOut'|'ALBRequestCount', 'ResourceLabel': 'string' }, 'PredefinedScalingMetricSpecification': { 'PredefinedMetricType': 'ASGAverageCPUUtilization'|'ASGAverageNetworkIn'|'ASGAverageNetworkOut'|'ALBRequestCountPerTarget', 'ResourceLabel': 'string' }, 'PredefinedLoadMetricSpecification': { 'PredefinedMetricType': 'ASGTotalCPUUtilization'|'ASGTotalNetworkIn'|'ASGTotalNetworkOut'|'ALBTargetGroupRequestCount', 'ResourceLabel': 'string' }, 'CustomizedScalingMetricSpecification': { 'MetricDataQueries': [ { 'Id': 'string', 'Expression': 'string', 'MetricStat': { 'Metric': { 'Namespace': 'string', 'MetricName': 'string', 'Dimensions': [ { 'Name': 'string', 'Value': 'string' }, ] }, 'Stat': 'string', 'Unit': 'string' }, 'Label': 'string', 'ReturnData': True|False }, ] }, 'CustomizedLoadMetricSpecification': { 'MetricDataQueries': [ { 'Id': 'string', 'Expression': 'string', 'MetricStat': { 'Metric': { 'Namespace': 'string', 'MetricName': 'string', 'Dimensions': [ { 'Name': 'string', 'Value': 'string' }, ] }, 'Stat': 'string', 'Unit': 'string' }, 'Label': 'string', 'ReturnData': True|False }, ] }, 'CustomizedCapacityMetricSpecification': { 'MetricDataQueries': [ { 'Id': 'string', 'Expression': 'string', 'MetricStat': { 'Metric': { 'Namespace': 'string', 'MetricName': 'string', 'Dimensions': [ { 'Name': 'string', 'Value': 'string' }, ] }, 'Stat': 'string', 'Unit': 'string' }, 'Label': 'string', 'ReturnData': True|False }, ] } }, ], 'Mode': 'ForecastAndScale'|'ForecastOnly', 'SchedulingBufferTime': 123, 'MaxCapacityBreachBehavior': 'HonorMaxCapacity'|'IncreaseMaxCapacity', 'MaxCapacityBuffer': 123 } }, ], 'NextToken': 'string' }
Response Structure
(dict) --
ScalingPolicies (list) --
The scaling policies.
(dict) --
Describes a scaling policy.
AutoScalingGroupName (string) --
The name of the Auto Scaling group.
PolicyName (string) --
The name of the scaling policy.
PolicyARN (string) --
The Amazon Resource Name (ARN) of the policy.
PolicyType (string) --
One of the following policy types:
TargetTrackingScaling
StepScaling
SimpleScaling (default)
PredictiveScaling
For more information, see Target tracking scaling policies and Step and simple scaling policies in the Amazon EC2 Auto Scaling User Guide.
AdjustmentType (string) --
Specifies how the scaling adjustment is interpreted (for example, an absolute number or a percentage). The valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.
MinAdjustmentStep (integer) --
Available for backward compatibility. Use MinAdjustmentMagnitude instead.
MinAdjustmentMagnitude (integer) --
The minimum value to scale by when the adjustment type is PercentChangeInCapacity.
ScalingAdjustment (integer) --
The amount by which to scale, based on the specified adjustment type. A positive value adds to the current capacity while a negative number removes from the current capacity.
Cooldown (integer) --
The duration of the policy's cooldown period, in seconds.
StepAdjustments (list) --
A set of adjustments that enable you to scale based on the size of the alarm breach.
(dict) --
Describes information used to create a step adjustment for a step scaling policy.
For the following examples, suppose that you have an alarm with a breach threshold of 50:
To trigger the adjustment when the metric is greater than or equal to 50 and less than 60, specify a lower bound of 0 and an upper bound of 10.
To trigger the adjustment when the metric is greater than 40 and less than or equal to 50, specify a lower bound of -10 and an upper bound of 0.
There are a few rules for the step adjustments for your step policy:
The ranges of your step adjustments can't overlap or have a gap.
At most, one step adjustment can have a null lower bound. If one step adjustment has a negative lower bound, then there must be a step adjustment with a null lower bound.
At most, one step adjustment can have a null upper bound. If one step adjustment has a positive upper bound, then there must be a step adjustment with a null upper bound.
The upper and lower bound can't be null in the same step adjustment.
For more information, see Step adjustments in the Amazon EC2 Auto Scaling User Guide.
MetricIntervalLowerBound (float) --
The lower bound for the difference between the alarm threshold and the CloudWatch metric. If the metric value is above the breach threshold, the lower bound is inclusive (the metric must be greater than or equal to the threshold plus the lower bound). Otherwise, it is exclusive (the metric must be greater than the threshold plus the lower bound). A null value indicates negative infinity.
MetricIntervalUpperBound (float) --
The upper bound for the difference between the alarm threshold and the CloudWatch metric. If the metric value is above the breach threshold, the upper bound is exclusive (the metric must be less than the threshold plus the upper bound). Otherwise, it is inclusive (the metric must be less than or equal to the threshold plus the upper bound). A null value indicates positive infinity.
The upper bound must be greater than the lower bound.
ScalingAdjustment (integer) --
The amount by which to scale, based on the specified adjustment type. A positive value adds to the current capacity while a negative number removes from the current capacity. For exact capacity, you must specify a non-negative value.
MetricAggregationType (string) --
The aggregation type for the CloudWatch metrics. The valid values are Minimum, Maximum, and Average.
EstimatedInstanceWarmup (integer) --
The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics.
Alarms (list) --
The CloudWatch alarms related to the policy.
(dict) --
Describes an alarm.
AlarmName (string) --
The name of the alarm.
AlarmARN (string) --
The Amazon Resource Name (ARN) of the alarm.
TargetTrackingConfiguration (dict) --
A target tracking scaling policy.
PredefinedMetricSpecification (dict) --
A predefined metric. You must specify either a predefined metric or a customized metric.
PredefinedMetricType (string) --
The metric type. The following predefined metrics are available:
ASGAverageCPUUtilization - Average CPU utilization of the Auto Scaling group.
ASGAverageNetworkIn - Average number of bytes received on all network interfaces by the Auto Scaling group.
ASGAverageNetworkOut - Average number of bytes sent out on all network interfaces by the Auto Scaling group.
ALBRequestCountPerTarget - Average Application Load Balancer request count per target for your Auto Scaling group.
ResourceLabel (string) --
A label that uniquely identifies a specific Application Load Balancer target group from which to determine the average request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.
You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:
app/my-alb/778d41231b141a0f/targetgroup/my-alb-target-group/943f017f100becff.
Where:
app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN
targetgroup/<target-group-name>/<target-group-id> is the final portion of the target group ARN.
To find the ARN for an Application Load Balancer, use the DescribeLoadBalancers API operation. To find the ARN for the target group, use the DescribeTargetGroups API operation.
CustomizedMetricSpecification (dict) --
A customized metric. You must specify either a predefined metric or a customized metric.
MetricName (string) --
The name of the metric. To get the exact metric name, namespace, and dimensions, inspect the Metric object that is returned by a call to ListMetrics.
Namespace (string) --
The namespace of the metric.
Dimensions (list) --
The dimensions of the metric.
Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.
(dict) --
Describes the dimension of a metric.
Name (string) --
The name of the dimension.
Value (string) --
The value of the dimension.
Statistic (string) --
The statistic of the metric.
Unit (string) --
The unit of the metric. For a complete list of the units that CloudWatch supports, see the MetricDatum data type in the Amazon CloudWatch API Reference.
Period (integer) --
The period of the metric in seconds. The default value is 60. Accepted values are 10, 30, and 60. For high resolution metric, set the value to less than 60. For more information, see Create a target tracking policy using high-resolution metrics for faster response.
Metrics (list) --
The metrics to include in the target tracking scaling policy, as a metric data query. This can include both raw metric and metric math expressions.
(dict) --
The metric data to return. Also defines whether this call is returning data for one metric only, or whether it is performing a math expression on the values of returned metric statistics to create a new time series. A time series is a series of data points, each of which is associated with a timestamp.
Id (string) --
A short name that identifies the object's results in the response. This name must be unique among all TargetTrackingMetricDataQuery objects specified for a single scaling policy. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscores. The first character must be a lowercase letter.
Expression (string) --
The math expression to perform on the returned data, if this object is performing a math expression. This expression can use the Id of the other metrics to refer to those metrics, and can also use the Id of other expressions to use the result of those expressions.
Conditional: Within each TargetTrackingMetricDataQuery object, you must specify either Expression or MetricStat, but not both.
MetricStat (dict) --
Information about the metric data to return.
Conditional: Within each TargetTrackingMetricDataQuery object, you must specify either Expression or MetricStat, but not both.
Metric (dict) --
The metric to use.
Namespace (string) --
The namespace of the metric. For more information, see the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
MetricName (string) --
The name of the metric.
Dimensions (list) --
The dimensions for the metric. For the list of available dimensions, see the Amazon Web Services documentation available from the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.
(dict) --
Describes the dimension of a metric.
Name (string) --
The name of the dimension.
Value (string) --
The value of the dimension.
Stat (string) --
The statistic to return. It can include any CloudWatch statistic or extended statistic. For a list of valid values, see the table in Statistics in the Amazon CloudWatch User Guide.
The most commonly used metric for scaling is Average.
Unit (string) --
The unit to use for the returned data points. For a complete list of the units that CloudWatch supports, see the MetricDatum data type in the Amazon CloudWatch API Reference.
Period (integer) --
The period of the metric in seconds. The default value is 60. Accepted values are 10, 30, and 60. For high resolution metric, set the value to less than 60. For more information, see Create a target tracking policy using high-resolution metrics for faster response.
Label (string) --
A human-readable label for this metric or expression. This is especially useful if this is a math expression, so that you know what the value represents.
Period (integer) --
The period of the metric in seconds. The default value is 60. Accepted values are 10, 30, and 60. For high resolution metric, set the value to less than 60. For more information, see Create a target tracking policy using high-resolution metrics for faster response.
ReturnData (boolean) --
Indicates whether to return the timestamps and raw data values of this metric.
If you use any math expressions, specify true for this value for only the final math expression that the metric specification is based on. You must specify false for ReturnData for all the other metrics and expressions used in the metric specification.
If you are only retrieving metrics and not performing any math expressions, do not specify anything for ReturnData. This sets it to its default ( true).
TargetValue (float) --
The target value for the metric.
DisableScaleIn (boolean) --
Indicates whether scaling in by the target tracking scaling policy is disabled. If scaling in is disabled, the target tracking scaling policy doesn't remove instances from the Auto Scaling group. Otherwise, the target tracking scaling policy can remove instances from the Auto Scaling group. The default is false.
Enabled (boolean) --
Indicates whether the policy is enabled ( true) or disabled ( false).
PredictiveScalingConfiguration (dict) --
A predictive scaling policy.
MetricSpecifications (list) --
This structure includes the metrics and target utilization to use for predictive scaling.
This is an array, but we currently only support a single metric specification. That is, you can specify a target value and a single metric pair, or a target value and one scaling metric and one load metric.
(dict) --
This structure specifies the metrics and target utilization settings for a predictive scaling policy.
You must specify either a metric pair, or a load metric and a scaling metric individually. Specifying a metric pair instead of individual metrics provides a simpler way to configure metrics for a scaling policy. You choose the metric pair, and the policy automatically knows the correct sum and average statistics to use for the load metric and the scaling metric.
Example
You create a predictive scaling policy and specify ALBRequestCount as the value for the metric pair and 1000.0 as the target value. For this type of metric, you must provide the metric dimension for the corresponding target group, so you also provide a resource label for the Application Load Balancer target group that is attached to your Auto Scaling group.
The number of requests the target group receives per minute provides the load metric, and the request count averaged between the members of the target group provides the scaling metric. In CloudWatch, this refers to the RequestCount and RequestCountPerTarget metrics, respectively.
For optimal use of predictive scaling, you adhere to the best practice of using a dynamic scaling policy to automatically scale between the minimum capacity and maximum capacity in response to real-time changes in resource utilization.
Amazon EC2 Auto Scaling consumes data points for the load metric over the last 14 days and creates an hourly load forecast for predictive scaling. (A minimum of 24 hours of data is required.)
After creating the load forecast, Amazon EC2 Auto Scaling determines when to reduce or increase the capacity of your Auto Scaling group in each hour of the forecast period so that the average number of requests received by each instance is as close to 1000 requests per minute as possible at all times.
For information about using custom metrics with predictive scaling, see Advanced predictive scaling policy configurations using custom metrics in the Amazon EC2 Auto Scaling User Guide.
TargetValue (float) --
Specifies the target utilization.
PredefinedMetricPairSpecification (dict) --
The predefined metric pair specification from which Amazon EC2 Auto Scaling determines the appropriate scaling metric and load metric to use.
PredefinedMetricType (string) --
Indicates which metrics to use. There are two different types of metrics for each metric type: one is a load metric and one is a scaling metric. For example, if the metric type is ASGCPUUtilization, the Auto Scaling group's total CPU metric is used as the load metric, and the average CPU metric is used for the scaling metric.
ResourceLabel (string) --
A label that uniquely identifies a specific Application Load Balancer target group from which to determine the total and average request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.
You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:
app/my-alb/778d41231b141a0f/targetgroup/my-alb-target-group/943f017f100becff.
Where:
app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN
targetgroup/<target-group-name>/<target-group-id> is the final portion of the target group ARN.
To find the ARN for an Application Load Balancer, use the DescribeLoadBalancers API operation. To find the ARN for the target group, use the DescribeTargetGroups API operation.
PredefinedScalingMetricSpecification (dict) --
The predefined scaling metric specification.
PredefinedMetricType (string) --
The metric type.
ResourceLabel (string) --
A label that uniquely identifies a specific Application Load Balancer target group from which to determine the average request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.
You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:
app/my-alb/778d41231b141a0f/targetgroup/my-alb-target-group/943f017f100becff.
Where:
app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN
targetgroup/<target-group-name>/<target-group-id> is the final portion of the target group ARN.
To find the ARN for an Application Load Balancer, use the DescribeLoadBalancers API operation. To find the ARN for the target group, use the DescribeTargetGroups API operation.
PredefinedLoadMetricSpecification (dict) --
The predefined load metric specification.
PredefinedMetricType (string) --
The metric type.
ResourceLabel (string) --
A label that uniquely identifies a specific Application Load Balancer target group from which to determine the request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.
You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:
app/my-alb/778d41231b141a0f/targetgroup/my-alb-target-group/943f017f100becff.
Where:
app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN
targetgroup/<target-group-name>/<target-group-id> is the final portion of the target group ARN.
To find the ARN for an Application Load Balancer, use the DescribeLoadBalancers API operation. To find the ARN for the target group, use the DescribeTargetGroups API operation.
CustomizedScalingMetricSpecification (dict) --
The customized scaling metric specification.
MetricDataQueries (list) --
One or more metric data queries to provide the data points for a scaling metric. Use multiple metric data queries only if you are performing a math expression on returned data.
(dict) --
The metric data to return. Also defines whether this call is returning data for one metric only, or whether it is performing a math expression on the values of returned metric statistics to create a new time series. A time series is a series of data points, each of which is associated with a timestamp.
For more information and examples, see Advanced predictive scaling policy configurations using custom metrics in the Amazon EC2 Auto Scaling User Guide.
Id (string) --
A short name that identifies the object's results in the response. This name must be unique among all MetricDataQuery objects specified for a single scaling policy. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscores. The first character must be a lowercase letter.
Expression (string) --
The math expression to perform on the returned data, if this object is performing a math expression. This expression can use the Id of the other metrics to refer to those metrics, and can also use the Id of other expressions to use the result of those expressions.
Conditional: Within each MetricDataQuery object, you must specify either Expression or MetricStat, but not both.
MetricStat (dict) --
Information about the metric data to return.
Conditional: Within each MetricDataQuery object, you must specify either Expression or MetricStat, but not both.
Metric (dict) --
The CloudWatch metric to return, including the metric name, namespace, and dimensions. To get the exact metric name, namespace, and dimensions, inspect the Metric object that is returned by a call to ListMetrics.
Namespace (string) --
The namespace of the metric. For more information, see the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
MetricName (string) --
The name of the metric.
Dimensions (list) --
The dimensions for the metric. For the list of available dimensions, see the Amazon Web Services documentation available from the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.
(dict) --
Describes the dimension of a metric.
Name (string) --
The name of the dimension.
Value (string) --
The value of the dimension.
Stat (string) --
The statistic to return. It can include any CloudWatch statistic or extended statistic. For a list of valid values, see the table in Statistics in the Amazon CloudWatch User Guide.
The most commonly used metrics for predictive scaling are Average and Sum.
Unit (string) --
The unit to use for the returned data points. For a complete list of the units that CloudWatch supports, see the MetricDatum data type in the Amazon CloudWatch API Reference.
Label (string) --
A human-readable label for this metric or expression. This is especially useful if this is a math expression, so that you know what the value represents.
ReturnData (boolean) --
Indicates whether to return the timestamps and raw data values of this metric.
If you use any math expressions, specify true for this value for only the final math expression that the metric specification is based on. You must specify false for ReturnData for all the other metrics and expressions used in the metric specification.
If you are only retrieving metrics and not performing any math expressions, do not specify anything for ReturnData. This sets it to its default ( true).
CustomizedLoadMetricSpecification (dict) --
The customized load metric specification.
MetricDataQueries (list) --
One or more metric data queries to provide the data points for a load metric. Use multiple metric data queries only if you are performing a math expression on returned data.
(dict) --
The metric data to return. Also defines whether this call is returning data for one metric only, or whether it is performing a math expression on the values of returned metric statistics to create a new time series. A time series is a series of data points, each of which is associated with a timestamp.
For more information and examples, see Advanced predictive scaling policy configurations using custom metrics in the Amazon EC2 Auto Scaling User Guide.
Id (string) --
A short name that identifies the object's results in the response. This name must be unique among all MetricDataQuery objects specified for a single scaling policy. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscores. The first character must be a lowercase letter.
Expression (string) --
The math expression to perform on the returned data, if this object is performing a math expression. This expression can use the Id of the other metrics to refer to those metrics, and can also use the Id of other expressions to use the result of those expressions.
Conditional: Within each MetricDataQuery object, you must specify either Expression or MetricStat, but not both.
MetricStat (dict) --
Information about the metric data to return.
Conditional: Within each MetricDataQuery object, you must specify either Expression or MetricStat, but not both.
Metric (dict) --
The CloudWatch metric to return, including the metric name, namespace, and dimensions. To get the exact metric name, namespace, and dimensions, inspect the Metric object that is returned by a call to ListMetrics.
Namespace (string) --
The namespace of the metric. For more information, see the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
MetricName (string) --
The name of the metric.
Dimensions (list) --
The dimensions for the metric. For the list of available dimensions, see the Amazon Web Services documentation available from the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.
(dict) --
Describes the dimension of a metric.
Name (string) --
The name of the dimension.
Value (string) --
The value of the dimension.
Stat (string) --
The statistic to return. It can include any CloudWatch statistic or extended statistic. For a list of valid values, see the table in Statistics in the Amazon CloudWatch User Guide.
The most commonly used metrics for predictive scaling are Average and Sum.
Unit (string) --
The unit to use for the returned data points. For a complete list of the units that CloudWatch supports, see the MetricDatum data type in the Amazon CloudWatch API Reference.
Label (string) --
A human-readable label for this metric or expression. This is especially useful if this is a math expression, so that you know what the value represents.
ReturnData (boolean) --
Indicates whether to return the timestamps and raw data values of this metric.
If you use any math expressions, specify true for this value for only the final math expression that the metric specification is based on. You must specify false for ReturnData for all the other metrics and expressions used in the metric specification.
If you are only retrieving metrics and not performing any math expressions, do not specify anything for ReturnData. This sets it to its default ( true).
CustomizedCapacityMetricSpecification (dict) --
The customized capacity metric specification.
MetricDataQueries (list) --
One or more metric data queries to provide the data points for a capacity metric. Use multiple metric data queries only if you are performing a math expression on returned data.
(dict) --
The metric data to return. Also defines whether this call is returning data for one metric only, or whether it is performing a math expression on the values of returned metric statistics to create a new time series. A time series is a series of data points, each of which is associated with a timestamp.
For more information and examples, see Advanced predictive scaling policy configurations using custom metrics in the Amazon EC2 Auto Scaling User Guide.
Id (string) --
A short name that identifies the object's results in the response. This name must be unique among all MetricDataQuery objects specified for a single scaling policy. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscores. The first character must be a lowercase letter.
Expression (string) --
The math expression to perform on the returned data, if this object is performing a math expression. This expression can use the Id of the other metrics to refer to those metrics, and can also use the Id of other expressions to use the result of those expressions.
Conditional: Within each MetricDataQuery object, you must specify either Expression or MetricStat, but not both.
MetricStat (dict) --
Information about the metric data to return.
Conditional: Within each MetricDataQuery object, you must specify either Expression or MetricStat, but not both.
Metric (dict) --
The CloudWatch metric to return, including the metric name, namespace, and dimensions. To get the exact metric name, namespace, and dimensions, inspect the Metric object that is returned by a call to ListMetrics.
Namespace (string) --
The namespace of the metric. For more information, see the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
MetricName (string) --
The name of the metric.
Dimensions (list) --
The dimensions for the metric. For the list of available dimensions, see the Amazon Web Services documentation available from the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.
(dict) --
Describes the dimension of a metric.
Name (string) --
The name of the dimension.
Value (string) --
The value of the dimension.
Stat (string) --
The statistic to return. It can include any CloudWatch statistic or extended statistic. For a list of valid values, see the table in Statistics in the Amazon CloudWatch User Guide.
The most commonly used metrics for predictive scaling are Average and Sum.
Unit (string) --
The unit to use for the returned data points. For a complete list of the units that CloudWatch supports, see the MetricDatum data type in the Amazon CloudWatch API Reference.
Label (string) --
A human-readable label for this metric or expression. This is especially useful if this is a math expression, so that you know what the value represents.
ReturnData (boolean) --
Indicates whether to return the timestamps and raw data values of this metric.
If you use any math expressions, specify true for this value for only the final math expression that the metric specification is based on. You must specify false for ReturnData for all the other metrics and expressions used in the metric specification.
If you are only retrieving metrics and not performing any math expressions, do not specify anything for ReturnData. This sets it to its default ( true).
Mode (string) --
The predictive scaling mode. Defaults to ForecastOnly if not specified.
SchedulingBufferTime (integer) --
The amount of time, in seconds, by which the instance launch time can be advanced. For example, the forecast says to add capacity at 10:00 AM, and you choose to pre-launch instances by 5 minutes. In that case, the instances will be launched at 9:55 AM. The intention is to give resources time to be provisioned. It can take a few minutes to launch an EC2 instance. The actual amount of time required depends on several factors, such as the size of the instance and whether there are startup scripts to complete.
The value must be less than the forecast interval duration of 3600 seconds (60 minutes). Defaults to 300 seconds if not specified.
MaxCapacityBreachBehavior (string) --
Defines the behavior that should be applied if the forecast capacity approaches or exceeds the maximum capacity of the Auto Scaling group. Defaults to HonorMaxCapacity if not specified.
The following are possible values:
HonorMaxCapacity - Amazon EC2 Auto Scaling can't increase the maximum capacity of the group when the forecast capacity is close to or exceeds the maximum capacity.
IncreaseMaxCapacity - Amazon EC2 Auto Scaling can increase the maximum capacity of the group when the forecast capacity is close to or exceeds the maximum capacity. The upper limit is determined by the forecasted capacity and the value for MaxCapacityBuffer.
MaxCapacityBuffer (integer) --
The size of the capacity buffer to use when the forecast capacity is close to or exceeds the maximum capacity. The value is specified as a percentage relative to the forecast capacity. For example, if the buffer is 10, this means a 10 percent buffer, such that if the forecast capacity is 50, and the maximum capacity is 40, then the effective maximum capacity is 55.
If set to 0, Amazon EC2 Auto Scaling may scale capacity higher than the maximum capacity to equal but not exceed forecast capacity.
Required if the MaxCapacityBreachBehavior property is set to IncreaseMaxCapacity, and cannot be used otherwise.
NextToken (string) --
A string that indicates that the response contains more items than can be returned in a single response. To receive additional items, specify this string for the NextToken value when requesting the next set of items. This value is null when there are no more items to return.
{'TargetTrackingConfiguration': {'CustomizedMetricSpecification': {'Metrics': {'MetricStat': {'Period': 'integer'}, 'Period': 'integer'}, 'Period': 'integer'}}}
Creates or updates a scaling policy for an Auto Scaling group. Scaling policies are used to scale an Auto Scaling group based on configurable metrics. If no policies are defined, the dynamic scaling and predictive scaling features are not used.
For more information about using dynamic scaling, see Target tracking scaling policies and Step and simple scaling policies in the Amazon EC2 Auto Scaling User Guide.
For more information about using predictive scaling, see Predictive scaling for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.
You can view the scaling policies for an Auto Scaling group using the DescribePolicies API call. If you are no longer using a scaling policy, you can delete it by calling the DeletePolicy API.
See also: AWS API Documentation
Request Syntax
client.put_scaling_policy( AutoScalingGroupName='string', PolicyName='string', PolicyType='string', AdjustmentType='string', MinAdjustmentStep=123, MinAdjustmentMagnitude=123, ScalingAdjustment=123, Cooldown=123, MetricAggregationType='string', StepAdjustments=[ { 'MetricIntervalLowerBound': 123.0, 'MetricIntervalUpperBound': 123.0, 'ScalingAdjustment': 123 }, ], EstimatedInstanceWarmup=123, TargetTrackingConfiguration={ 'PredefinedMetricSpecification': { 'PredefinedMetricType': 'ASGAverageCPUUtilization'|'ASGAverageNetworkIn'|'ASGAverageNetworkOut'|'ALBRequestCountPerTarget', 'ResourceLabel': 'string' }, 'CustomizedMetricSpecification': { 'MetricName': 'string', 'Namespace': 'string', 'Dimensions': [ { 'Name': 'string', 'Value': 'string' }, ], 'Statistic': 'Average'|'Minimum'|'Maximum'|'SampleCount'|'Sum', 'Unit': 'string', 'Period': 123, 'Metrics': [ { 'Id': 'string', 'Expression': 'string', 'MetricStat': { 'Metric': { 'Namespace': 'string', 'MetricName': 'string', 'Dimensions': [ { 'Name': 'string', 'Value': 'string' }, ] }, 'Stat': 'string', 'Unit': 'string', 'Period': 123 }, 'Label': 'string', 'Period': 123, 'ReturnData': True|False }, ] }, 'TargetValue': 123.0, 'DisableScaleIn': True|False }, Enabled=True|False, PredictiveScalingConfiguration={ 'MetricSpecifications': [ { 'TargetValue': 123.0, 'PredefinedMetricPairSpecification': { 'PredefinedMetricType': 'ASGCPUUtilization'|'ASGNetworkIn'|'ASGNetworkOut'|'ALBRequestCount', 'ResourceLabel': 'string' }, 'PredefinedScalingMetricSpecification': { 'PredefinedMetricType': 'ASGAverageCPUUtilization'|'ASGAverageNetworkIn'|'ASGAverageNetworkOut'|'ALBRequestCountPerTarget', 'ResourceLabel': 'string' }, 'PredefinedLoadMetricSpecification': { 'PredefinedMetricType': 'ASGTotalCPUUtilization'|'ASGTotalNetworkIn'|'ASGTotalNetworkOut'|'ALBTargetGroupRequestCount', 'ResourceLabel': 'string' }, 'CustomizedScalingMetricSpecification': { 'MetricDataQueries': [ { 'Id': 'string', 'Expression': 'string', 'MetricStat': { 'Metric': { 'Namespace': 'string', 'MetricName': 'string', 'Dimensions': [ { 'Name': 'string', 'Value': 'string' }, ] }, 'Stat': 'string', 'Unit': 'string' }, 'Label': 'string', 'ReturnData': True|False }, ] }, 'CustomizedLoadMetricSpecification': { 'MetricDataQueries': [ { 'Id': 'string', 'Expression': 'string', 'MetricStat': { 'Metric': { 'Namespace': 'string', 'MetricName': 'string', 'Dimensions': [ { 'Name': 'string', 'Value': 'string' }, ] }, 'Stat': 'string', 'Unit': 'string' }, 'Label': 'string', 'ReturnData': True|False }, ] }, 'CustomizedCapacityMetricSpecification': { 'MetricDataQueries': [ { 'Id': 'string', 'Expression': 'string', 'MetricStat': { 'Metric': { 'Namespace': 'string', 'MetricName': 'string', 'Dimensions': [ { 'Name': 'string', 'Value': 'string' }, ] }, 'Stat': 'string', 'Unit': 'string' }, 'Label': 'string', 'ReturnData': True|False }, ] } }, ], 'Mode': 'ForecastAndScale'|'ForecastOnly', 'SchedulingBufferTime': 123, 'MaxCapacityBreachBehavior': 'HonorMaxCapacity'|'IncreaseMaxCapacity', 'MaxCapacityBuffer': 123 } )
string
[REQUIRED]
The name of the Auto Scaling group.
string
[REQUIRED]
The name of the policy.
string
One of the following policy types:
TargetTrackingScaling
StepScaling
SimpleScaling (default)
PredictiveScaling
string
Specifies how the scaling adjustment is interpreted (for example, an absolute number or a percentage). The valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.
Required if the policy type is StepScaling or SimpleScaling. For more information, see Scaling adjustment types in the Amazon EC2 Auto Scaling User Guide.
integer
Available for backward compatibility. Use MinAdjustmentMagnitude instead.
integer
The minimum value to scale by when the adjustment type is PercentChangeInCapacity. For example, suppose that you create a step scaling policy to scale out an Auto Scaling group by 25 percent and you specify a MinAdjustmentMagnitude of 2. If the group has 4 instances and the scaling policy is performed, 25 percent of 4 is 1. However, because you specified a MinAdjustmentMagnitude of 2, Amazon EC2 Auto Scaling scales out the group by 2 instances.
Valid only if the policy type is StepScaling or SimpleScaling. For more information, see Scaling adjustment types in the Amazon EC2 Auto Scaling User Guide.
integer
The amount by which to scale, based on the specified adjustment type. A positive value adds to the current capacity while a negative number removes from the current capacity. For exact capacity, you must specify a non-negative value.
Required if the policy type is SimpleScaling. (Not used with any other policy type.)
integer
A cooldown period, in seconds, that applies to a specific simple scaling policy. When a cooldown period is specified here, it overrides the default cooldown.
Valid only if the policy type is SimpleScaling. For more information, see Scaling cooldowns for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.
Default: None
string
The aggregation type for the CloudWatch metrics. The valid values are Minimum, Maximum, and Average. If the aggregation type is null, the value is treated as Average.
Valid only if the policy type is StepScaling.
list
A set of adjustments that enable you to scale based on the size of the alarm breach.
Required if the policy type is StepScaling. (Not used with any other policy type.)
(dict) --
Describes information used to create a step adjustment for a step scaling policy.
For the following examples, suppose that you have an alarm with a breach threshold of 50:
To trigger the adjustment when the metric is greater than or equal to 50 and less than 60, specify a lower bound of 0 and an upper bound of 10.
To trigger the adjustment when the metric is greater than 40 and less than or equal to 50, specify a lower bound of -10 and an upper bound of 0.
There are a few rules for the step adjustments for your step policy:
The ranges of your step adjustments can't overlap or have a gap.
At most, one step adjustment can have a null lower bound. If one step adjustment has a negative lower bound, then there must be a step adjustment with a null lower bound.
At most, one step adjustment can have a null upper bound. If one step adjustment has a positive upper bound, then there must be a step adjustment with a null upper bound.
The upper and lower bound can't be null in the same step adjustment.
For more information, see Step adjustments in the Amazon EC2 Auto Scaling User Guide.
MetricIntervalLowerBound (float) --
The lower bound for the difference between the alarm threshold and the CloudWatch metric. If the metric value is above the breach threshold, the lower bound is inclusive (the metric must be greater than or equal to the threshold plus the lower bound). Otherwise, it is exclusive (the metric must be greater than the threshold plus the lower bound). A null value indicates negative infinity.
MetricIntervalUpperBound (float) --
The upper bound for the difference between the alarm threshold and the CloudWatch metric. If the metric value is above the breach threshold, the upper bound is exclusive (the metric must be less than the threshold plus the upper bound). Otherwise, it is inclusive (the metric must be less than or equal to the threshold plus the upper bound). A null value indicates positive infinity.
The upper bound must be greater than the lower bound.
ScalingAdjustment (integer) -- [REQUIRED]
The amount by which to scale, based on the specified adjustment type. A positive value adds to the current capacity while a negative number removes from the current capacity. For exact capacity, you must specify a non-negative value.
integer
Not needed if the default instance warmup is defined for the group.
The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. This warm-up period applies to instances launched due to a specific target tracking or step scaling policy. When a warm-up period is specified here, it overrides the default instance warmup.
Valid only if the policy type is TargetTrackingScaling or StepScaling.
dict
A target tracking scaling policy. Provides support for predefined or custom metrics.
The following predefined metrics are available:
ASGAverageCPUUtilization
ASGAverageNetworkIn
ASGAverageNetworkOut
ALBRequestCountPerTarget
If you specify ALBRequestCountPerTarget for the metric, you must specify the ResourceLabel property with the PredefinedMetricSpecification.
For more information, see TargetTrackingConfiguration in the Amazon EC2 Auto Scaling API Reference.
Required if the policy type is TargetTrackingScaling.
PredefinedMetricSpecification (dict) --
A predefined metric. You must specify either a predefined metric or a customized metric.
PredefinedMetricType (string) -- [REQUIRED]
The metric type. The following predefined metrics are available:
ASGAverageCPUUtilization - Average CPU utilization of the Auto Scaling group.
ASGAverageNetworkIn - Average number of bytes received on all network interfaces by the Auto Scaling group.
ASGAverageNetworkOut - Average number of bytes sent out on all network interfaces by the Auto Scaling group.
ALBRequestCountPerTarget - Average Application Load Balancer request count per target for your Auto Scaling group.
ResourceLabel (string) --
A label that uniquely identifies a specific Application Load Balancer target group from which to determine the average request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.
You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:
app/my-alb/778d41231b141a0f/targetgroup/my-alb-target-group/943f017f100becff.
Where:
app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN
targetgroup/<target-group-name>/<target-group-id> is the final portion of the target group ARN.
To find the ARN for an Application Load Balancer, use the DescribeLoadBalancers API operation. To find the ARN for the target group, use the DescribeTargetGroups API operation.
CustomizedMetricSpecification (dict) --
A customized metric. You must specify either a predefined metric or a customized metric.
MetricName (string) --
The name of the metric. To get the exact metric name, namespace, and dimensions, inspect the Metric object that is returned by a call to ListMetrics.
Namespace (string) --
The namespace of the metric.
Dimensions (list) --
The dimensions of the metric.
Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.
(dict) --
Describes the dimension of a metric.
Name (string) -- [REQUIRED]
The name of the dimension.
Value (string) -- [REQUIRED]
The value of the dimension.
Statistic (string) --
The statistic of the metric.
Unit (string) --
The unit of the metric. For a complete list of the units that CloudWatch supports, see the MetricDatum data type in the Amazon CloudWatch API Reference.
Period (integer) --
The period of the metric in seconds. The default value is 60. Accepted values are 10, 30, and 60. For high resolution metric, set the value to less than 60. For more information, see Create a target tracking policy using high-resolution metrics for faster response.
Metrics (list) --
The metrics to include in the target tracking scaling policy, as a metric data query. This can include both raw metric and metric math expressions.
(dict) --
The metric data to return. Also defines whether this call is returning data for one metric only, or whether it is performing a math expression on the values of returned metric statistics to create a new time series. A time series is a series of data points, each of which is associated with a timestamp.
Id (string) -- [REQUIRED]
A short name that identifies the object's results in the response. This name must be unique among all TargetTrackingMetricDataQuery objects specified for a single scaling policy. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscores. The first character must be a lowercase letter.
Expression (string) --
The math expression to perform on the returned data, if this object is performing a math expression. This expression can use the Id of the other metrics to refer to those metrics, and can also use the Id of other expressions to use the result of those expressions.
Conditional: Within each TargetTrackingMetricDataQuery object, you must specify either Expression or MetricStat, but not both.
MetricStat (dict) --
Information about the metric data to return.
Conditional: Within each TargetTrackingMetricDataQuery object, you must specify either Expression or MetricStat, but not both.
Metric (dict) -- [REQUIRED]
The metric to use.
Namespace (string) -- [REQUIRED]
The namespace of the metric. For more information, see the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
MetricName (string) -- [REQUIRED]
The name of the metric.
Dimensions (list) --
The dimensions for the metric. For the list of available dimensions, see the Amazon Web Services documentation available from the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.
(dict) --
Describes the dimension of a metric.
Name (string) -- [REQUIRED]
The name of the dimension.
Value (string) -- [REQUIRED]
The value of the dimension.
Stat (string) -- [REQUIRED]
The statistic to return. It can include any CloudWatch statistic or extended statistic. For a list of valid values, see the table in Statistics in the Amazon CloudWatch User Guide.
The most commonly used metric for scaling is Average.
Unit (string) --
The unit to use for the returned data points. For a complete list of the units that CloudWatch supports, see the MetricDatum data type in the Amazon CloudWatch API Reference.
Period (integer) --
The period of the metric in seconds. The default value is 60. Accepted values are 10, 30, and 60. For high resolution metric, set the value to less than 60. For more information, see Create a target tracking policy using high-resolution metrics for faster response.
Label (string) --
A human-readable label for this metric or expression. This is especially useful if this is a math expression, so that you know what the value represents.
Period (integer) --
The period of the metric in seconds. The default value is 60. Accepted values are 10, 30, and 60. For high resolution metric, set the value to less than 60. For more information, see Create a target tracking policy using high-resolution metrics for faster response.
ReturnData (boolean) --
Indicates whether to return the timestamps and raw data values of this metric.
If you use any math expressions, specify true for this value for only the final math expression that the metric specification is based on. You must specify false for ReturnData for all the other metrics and expressions used in the metric specification.
If you are only retrieving metrics and not performing any math expressions, do not specify anything for ReturnData. This sets it to its default ( true).
TargetValue (float) -- [REQUIRED]
The target value for the metric.
DisableScaleIn (boolean) --
Indicates whether scaling in by the target tracking scaling policy is disabled. If scaling in is disabled, the target tracking scaling policy doesn't remove instances from the Auto Scaling group. Otherwise, the target tracking scaling policy can remove instances from the Auto Scaling group. The default is false.
boolean
Indicates whether the scaling policy is enabled or disabled. The default is enabled. For more information, see Disable a scaling policy for an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.
dict
A predictive scaling policy. Provides support for predefined and custom metrics.
Predefined metrics include CPU utilization, network in/out, and the Application Load Balancer request count.
For more information, see PredictiveScalingConfiguration in the Amazon EC2 Auto Scaling API Reference.
Required if the policy type is PredictiveScaling.
MetricSpecifications (list) -- [REQUIRED]
This structure includes the metrics and target utilization to use for predictive scaling.
This is an array, but we currently only support a single metric specification. That is, you can specify a target value and a single metric pair, or a target value and one scaling metric and one load metric.
(dict) --
This structure specifies the metrics and target utilization settings for a predictive scaling policy.
You must specify either a metric pair, or a load metric and a scaling metric individually. Specifying a metric pair instead of individual metrics provides a simpler way to configure metrics for a scaling policy. You choose the metric pair, and the policy automatically knows the correct sum and average statistics to use for the load metric and the scaling metric.
Example
You create a predictive scaling policy and specify ALBRequestCount as the value for the metric pair and 1000.0 as the target value. For this type of metric, you must provide the metric dimension for the corresponding target group, so you also provide a resource label for the Application Load Balancer target group that is attached to your Auto Scaling group.
The number of requests the target group receives per minute provides the load metric, and the request count averaged between the members of the target group provides the scaling metric. In CloudWatch, this refers to the RequestCount and RequestCountPerTarget metrics, respectively.
For optimal use of predictive scaling, you adhere to the best practice of using a dynamic scaling policy to automatically scale between the minimum capacity and maximum capacity in response to real-time changes in resource utilization.
Amazon EC2 Auto Scaling consumes data points for the load metric over the last 14 days and creates an hourly load forecast for predictive scaling. (A minimum of 24 hours of data is required.)
After creating the load forecast, Amazon EC2 Auto Scaling determines when to reduce or increase the capacity of your Auto Scaling group in each hour of the forecast period so that the average number of requests received by each instance is as close to 1000 requests per minute as possible at all times.
For information about using custom metrics with predictive scaling, see Advanced predictive scaling policy configurations using custom metrics in the Amazon EC2 Auto Scaling User Guide.
TargetValue (float) -- [REQUIRED]
Specifies the target utilization.
PredefinedMetricPairSpecification (dict) --
The predefined metric pair specification from which Amazon EC2 Auto Scaling determines the appropriate scaling metric and load metric to use.
PredefinedMetricType (string) -- [REQUIRED]
Indicates which metrics to use. There are two different types of metrics for each metric type: one is a load metric and one is a scaling metric. For example, if the metric type is ASGCPUUtilization, the Auto Scaling group's total CPU metric is used as the load metric, and the average CPU metric is used for the scaling metric.
ResourceLabel (string) --
A label that uniquely identifies a specific Application Load Balancer target group from which to determine the total and average request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.
You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:
app/my-alb/778d41231b141a0f/targetgroup/my-alb-target-group/943f017f100becff.
Where:
app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN
targetgroup/<target-group-name>/<target-group-id> is the final portion of the target group ARN.
To find the ARN for an Application Load Balancer, use the DescribeLoadBalancers API operation. To find the ARN for the target group, use the DescribeTargetGroups API operation.
PredefinedScalingMetricSpecification (dict) --
The predefined scaling metric specification.
PredefinedMetricType (string) -- [REQUIRED]
The metric type.
ResourceLabel (string) --
A label that uniquely identifies a specific Application Load Balancer target group from which to determine the average request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.
You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:
app/my-alb/778d41231b141a0f/targetgroup/my-alb-target-group/943f017f100becff.
Where:
app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN
targetgroup/<target-group-name>/<target-group-id> is the final portion of the target group ARN.
To find the ARN for an Application Load Balancer, use the DescribeLoadBalancers API operation. To find the ARN for the target group, use the DescribeTargetGroups API operation.
PredefinedLoadMetricSpecification (dict) --
The predefined load metric specification.
PredefinedMetricType (string) -- [REQUIRED]
The metric type.
ResourceLabel (string) --
A label that uniquely identifies a specific Application Load Balancer target group from which to determine the request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.
You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:
app/my-alb/778d41231b141a0f/targetgroup/my-alb-target-group/943f017f100becff.
Where:
app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN
targetgroup/<target-group-name>/<target-group-id> is the final portion of the target group ARN.
To find the ARN for an Application Load Balancer, use the DescribeLoadBalancers API operation. To find the ARN for the target group, use the DescribeTargetGroups API operation.
CustomizedScalingMetricSpecification (dict) --
The customized scaling metric specification.
MetricDataQueries (list) -- [REQUIRED]
One or more metric data queries to provide the data points for a scaling metric. Use multiple metric data queries only if you are performing a math expression on returned data.
(dict) --
The metric data to return. Also defines whether this call is returning data for one metric only, or whether it is performing a math expression on the values of returned metric statistics to create a new time series. A time series is a series of data points, each of which is associated with a timestamp.
For more information and examples, see Advanced predictive scaling policy configurations using custom metrics in the Amazon EC2 Auto Scaling User Guide.
Id (string) -- [REQUIRED]
A short name that identifies the object's results in the response. This name must be unique among all MetricDataQuery objects specified for a single scaling policy. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscores. The first character must be a lowercase letter.
Expression (string) --
The math expression to perform on the returned data, if this object is performing a math expression. This expression can use the Id of the other metrics to refer to those metrics, and can also use the Id of other expressions to use the result of those expressions.
Conditional: Within each MetricDataQuery object, you must specify either Expression or MetricStat, but not both.
MetricStat (dict) --
Information about the metric data to return.
Conditional: Within each MetricDataQuery object, you must specify either Expression or MetricStat, but not both.
Metric (dict) -- [REQUIRED]
The CloudWatch metric to return, including the metric name, namespace, and dimensions. To get the exact metric name, namespace, and dimensions, inspect the Metric object that is returned by a call to ListMetrics.
Namespace (string) -- [REQUIRED]
The namespace of the metric. For more information, see the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
MetricName (string) -- [REQUIRED]
The name of the metric.
Dimensions (list) --
The dimensions for the metric. For the list of available dimensions, see the Amazon Web Services documentation available from the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.
(dict) --
Describes the dimension of a metric.
Name (string) -- [REQUIRED]
The name of the dimension.
Value (string) -- [REQUIRED]
The value of the dimension.
Stat (string) -- [REQUIRED]
The statistic to return. It can include any CloudWatch statistic or extended statistic. For a list of valid values, see the table in Statistics in the Amazon CloudWatch User Guide.
The most commonly used metrics for predictive scaling are Average and Sum.
Unit (string) --
The unit to use for the returned data points. For a complete list of the units that CloudWatch supports, see the MetricDatum data type in the Amazon CloudWatch API Reference.
Label (string) --
A human-readable label for this metric or expression. This is especially useful if this is a math expression, so that you know what the value represents.
ReturnData (boolean) --
Indicates whether to return the timestamps and raw data values of this metric.
If you use any math expressions, specify true for this value for only the final math expression that the metric specification is based on. You must specify false for ReturnData for all the other metrics and expressions used in the metric specification.
If you are only retrieving metrics and not performing any math expressions, do not specify anything for ReturnData. This sets it to its default ( true).
CustomizedLoadMetricSpecification (dict) --
The customized load metric specification.
MetricDataQueries (list) -- [REQUIRED]
One or more metric data queries to provide the data points for a load metric. Use multiple metric data queries only if you are performing a math expression on returned data.
(dict) --
The metric data to return. Also defines whether this call is returning data for one metric only, or whether it is performing a math expression on the values of returned metric statistics to create a new time series. A time series is a series of data points, each of which is associated with a timestamp.
For more information and examples, see Advanced predictive scaling policy configurations using custom metrics in the Amazon EC2 Auto Scaling User Guide.
Id (string) -- [REQUIRED]
A short name that identifies the object's results in the response. This name must be unique among all MetricDataQuery objects specified for a single scaling policy. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscores. The first character must be a lowercase letter.
Expression (string) --
The math expression to perform on the returned data, if this object is performing a math expression. This expression can use the Id of the other metrics to refer to those metrics, and can also use the Id of other expressions to use the result of those expressions.
Conditional: Within each MetricDataQuery object, you must specify either Expression or MetricStat, but not both.
MetricStat (dict) --
Information about the metric data to return.
Conditional: Within each MetricDataQuery object, you must specify either Expression or MetricStat, but not both.
Metric (dict) -- [REQUIRED]
The CloudWatch metric to return, including the metric name, namespace, and dimensions. To get the exact metric name, namespace, and dimensions, inspect the Metric object that is returned by a call to ListMetrics.
Namespace (string) -- [REQUIRED]
The namespace of the metric. For more information, see the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
MetricName (string) -- [REQUIRED]
The name of the metric.
Dimensions (list) --
The dimensions for the metric. For the list of available dimensions, see the Amazon Web Services documentation available from the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.
(dict) --
Describes the dimension of a metric.
Name (string) -- [REQUIRED]
The name of the dimension.
Value (string) -- [REQUIRED]
The value of the dimension.
Stat (string) -- [REQUIRED]
The statistic to return. It can include any CloudWatch statistic or extended statistic. For a list of valid values, see the table in Statistics in the Amazon CloudWatch User Guide.
The most commonly used metrics for predictive scaling are Average and Sum.
Unit (string) --
The unit to use for the returned data points. For a complete list of the units that CloudWatch supports, see the MetricDatum data type in the Amazon CloudWatch API Reference.
Label (string) --
A human-readable label for this metric or expression. This is especially useful if this is a math expression, so that you know what the value represents.
ReturnData (boolean) --
Indicates whether to return the timestamps and raw data values of this metric.
If you use any math expressions, specify true for this value for only the final math expression that the metric specification is based on. You must specify false for ReturnData for all the other metrics and expressions used in the metric specification.
If you are only retrieving metrics and not performing any math expressions, do not specify anything for ReturnData. This sets it to its default ( true).
CustomizedCapacityMetricSpecification (dict) --
The customized capacity metric specification.
MetricDataQueries (list) -- [REQUIRED]
One or more metric data queries to provide the data points for a capacity metric. Use multiple metric data queries only if you are performing a math expression on returned data.
(dict) --
The metric data to return. Also defines whether this call is returning data for one metric only, or whether it is performing a math expression on the values of returned metric statistics to create a new time series. A time series is a series of data points, each of which is associated with a timestamp.
For more information and examples, see Advanced predictive scaling policy configurations using custom metrics in the Amazon EC2 Auto Scaling User Guide.
Id (string) -- [REQUIRED]
A short name that identifies the object's results in the response. This name must be unique among all MetricDataQuery objects specified for a single scaling policy. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscores. The first character must be a lowercase letter.
Expression (string) --
The math expression to perform on the returned data, if this object is performing a math expression. This expression can use the Id of the other metrics to refer to those metrics, and can also use the Id of other expressions to use the result of those expressions.
Conditional: Within each MetricDataQuery object, you must specify either Expression or MetricStat, but not both.
MetricStat (dict) --
Information about the metric data to return.
Conditional: Within each MetricDataQuery object, you must specify either Expression or MetricStat, but not both.
Metric (dict) -- [REQUIRED]
The CloudWatch metric to return, including the metric name, namespace, and dimensions. To get the exact metric name, namespace, and dimensions, inspect the Metric object that is returned by a call to ListMetrics.
Namespace (string) -- [REQUIRED]
The namespace of the metric. For more information, see the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
MetricName (string) -- [REQUIRED]
The name of the metric.
Dimensions (list) --
The dimensions for the metric. For the list of available dimensions, see the Amazon Web Services documentation available from the table in Amazon Web Services services that publish CloudWatch metrics in the Amazon CloudWatch User Guide.
Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.
(dict) --
Describes the dimension of a metric.
Name (string) -- [REQUIRED]
The name of the dimension.
Value (string) -- [REQUIRED]
The value of the dimension.
Stat (string) -- [REQUIRED]
The statistic to return. It can include any CloudWatch statistic or extended statistic. For a list of valid values, see the table in Statistics in the Amazon CloudWatch User Guide.
The most commonly used metrics for predictive scaling are Average and Sum.
Unit (string) --
The unit to use for the returned data points. For a complete list of the units that CloudWatch supports, see the MetricDatum data type in the Amazon CloudWatch API Reference.
Label (string) --
A human-readable label for this metric or expression. This is especially useful if this is a math expression, so that you know what the value represents.
ReturnData (boolean) --
Indicates whether to return the timestamps and raw data values of this metric.
If you use any math expressions, specify true for this value for only the final math expression that the metric specification is based on. You must specify false for ReturnData for all the other metrics and expressions used in the metric specification.
If you are only retrieving metrics and not performing any math expressions, do not specify anything for ReturnData. This sets it to its default ( true).
Mode (string) --
The predictive scaling mode. Defaults to ForecastOnly if not specified.
SchedulingBufferTime (integer) --
The amount of time, in seconds, by which the instance launch time can be advanced. For example, the forecast says to add capacity at 10:00 AM, and you choose to pre-launch instances by 5 minutes. In that case, the instances will be launched at 9:55 AM. The intention is to give resources time to be provisioned. It can take a few minutes to launch an EC2 instance. The actual amount of time required depends on several factors, such as the size of the instance and whether there are startup scripts to complete.
The value must be less than the forecast interval duration of 3600 seconds (60 minutes). Defaults to 300 seconds if not specified.
MaxCapacityBreachBehavior (string) --
Defines the behavior that should be applied if the forecast capacity approaches or exceeds the maximum capacity of the Auto Scaling group. Defaults to HonorMaxCapacity if not specified.
The following are possible values:
HonorMaxCapacity - Amazon EC2 Auto Scaling can't increase the maximum capacity of the group when the forecast capacity is close to or exceeds the maximum capacity.
IncreaseMaxCapacity - Amazon EC2 Auto Scaling can increase the maximum capacity of the group when the forecast capacity is close to or exceeds the maximum capacity. The upper limit is determined by the forecasted capacity and the value for MaxCapacityBuffer.
MaxCapacityBuffer (integer) --
The size of the capacity buffer to use when the forecast capacity is close to or exceeds the maximum capacity. The value is specified as a percentage relative to the forecast capacity. For example, if the buffer is 10, this means a 10 percent buffer, such that if the forecast capacity is 50, and the maximum capacity is 40, then the effective maximum capacity is 55.
If set to 0, Amazon EC2 Auto Scaling may scale capacity higher than the maximum capacity to equal but not exceed forecast capacity.
Required if the MaxCapacityBreachBehavior property is set to IncreaseMaxCapacity, and cannot be used otherwise.
dict
Response Syntax
{ 'PolicyARN': 'string', 'Alarms': [ { 'AlarmName': 'string', 'AlarmARN': 'string' }, ] }
Response Structure
(dict) --
Contains the output of PutScalingPolicy.
PolicyARN (string) --
The Amazon Resource Name (ARN) of the policy.
Alarms (list) --
The CloudWatch alarms created for the target tracking scaling policy.
(dict) --
Describes an alarm.
AlarmName (string) --
The name of the alarm.
AlarmARN (string) --
The Amazon Resource Name (ARN) of the alarm.