Class: AWSCDK::Autoscaling::CfnScalingPolicy::PredictiveScalingMetricSpecificationProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
autoscaling/cfn_scaling_policy.rb

Overview

A structure that specifies a metric specification for the MetricSpecifications property of the AWS::AutoScaling::ScalingPolicy PredictiveScalingConfiguration property type.

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 .

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target_value:, customized_capacity_metric_specification: nil, customized_load_metric_specification: nil, customized_scaling_metric_specification: nil, predefined_load_metric_specification: nil, predefined_metric_pair_specification: nil, predefined_scaling_metric_specification: nil) ⇒ PredictiveScalingMetricSpecificationProperty

Returns a new instance of PredictiveScalingMetricSpecificationProperty.

Parameters:



1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
# File 'autoscaling/cfn_scaling_policy.rb', line 1319

def initialize(target_value:, customized_capacity_metric_specification: nil, customized_load_metric_specification: nil, customized_scaling_metric_specification: nil, predefined_load_metric_specification: nil, predefined_metric_pair_specification: nil, predefined_scaling_metric_specification: nil)
  @target_value = target_value
  Jsii::Type.check_type(@target_value, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "targetValue")
  @customized_capacity_metric_specification = customized_capacity_metric_specification.is_a?(Hash) ? ::AWSCDK::Autoscaling::CfnScalingPolicy::PredictiveScalingCustomizedCapacityMetricProperty.new(**customized_capacity_metric_specification.transform_keys(&:to_sym)) : customized_capacity_metric_specification
  Jsii::Type.check_type(@customized_capacity_metric_specification, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5DZm5TY2FsaW5nUG9saWN5LlByZWRpY3RpdmVTY2FsaW5nQ3VzdG9taXplZENhcGFjaXR5TWV0cmljUHJvcGVydHkifV19fQ==")), "customizedCapacityMetricSpecification") unless @customized_capacity_metric_specification.nil?
  @customized_load_metric_specification = customized_load_metric_specification.is_a?(Hash) ? ::AWSCDK::Autoscaling::CfnScalingPolicy::PredictiveScalingCustomizedLoadMetricProperty.new(**customized_load_metric_specification.transform_keys(&:to_sym)) : customized_load_metric_specification
  Jsii::Type.check_type(@customized_load_metric_specification, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5DZm5TY2FsaW5nUG9saWN5LlByZWRpY3RpdmVTY2FsaW5nQ3VzdG9taXplZExvYWRNZXRyaWNQcm9wZXJ0eSJ9XX19")), "customizedLoadMetricSpecification") unless @customized_load_metric_specification.nil?
  @customized_scaling_metric_specification = customized_scaling_metric_specification.is_a?(Hash) ? ::AWSCDK::Autoscaling::CfnScalingPolicy::PredictiveScalingCustomizedScalingMetricProperty.new(**customized_scaling_metric_specification.transform_keys(&:to_sym)) : customized_scaling_metric_specification
  Jsii::Type.check_type(@customized_scaling_metric_specification, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5DZm5TY2FsaW5nUG9saWN5LlByZWRpY3RpdmVTY2FsaW5nQ3VzdG9taXplZFNjYWxpbmdNZXRyaWNQcm9wZXJ0eSJ9XX19")), "customizedScalingMetricSpecification") unless @customized_scaling_metric_specification.nil?
  @predefined_load_metric_specification = predefined_load_metric_specification.is_a?(Hash) ? ::AWSCDK::Autoscaling::CfnScalingPolicy::PredictiveScalingPredefinedLoadMetricProperty.new(**predefined_load_metric_specification.transform_keys(&:to_sym)) : predefined_load_metric_specification
  Jsii::Type.check_type(@predefined_load_metric_specification, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5DZm5TY2FsaW5nUG9saWN5LlByZWRpY3RpdmVTY2FsaW5nUHJlZGVmaW5lZExvYWRNZXRyaWNQcm9wZXJ0eSJ9XX19")), "predefinedLoadMetricSpecification") unless @predefined_load_metric_specification.nil?
  @predefined_metric_pair_specification = predefined_metric_pair_specification.is_a?(Hash) ? ::AWSCDK::Autoscaling::CfnScalingPolicy::PredictiveScalingPredefinedMetricPairProperty.new(**predefined_metric_pair_specification.transform_keys(&:to_sym)) : predefined_metric_pair_specification
  Jsii::Type.check_type(@predefined_metric_pair_specification, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5DZm5TY2FsaW5nUG9saWN5LlByZWRpY3RpdmVTY2FsaW5nUHJlZGVmaW5lZE1ldHJpY1BhaXJQcm9wZXJ0eSJ9XX19")), "predefinedMetricPairSpecification") unless @predefined_metric_pair_specification.nil?
  @predefined_scaling_metric_specification = predefined_scaling_metric_specification.is_a?(Hash) ? ::AWSCDK::Autoscaling::CfnScalingPolicy::PredictiveScalingPredefinedScalingMetricProperty.new(**predefined_scaling_metric_specification.transform_keys(&:to_sym)) : predefined_scaling_metric_specification
  Jsii::Type.check_type(@predefined_scaling_metric_specification, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5DZm5TY2FsaW5nUG9saWN5LlByZWRpY3RpdmVTY2FsaW5nUHJlZGVmaW5lZFNjYWxpbmdNZXRyaWNQcm9wZXJ0eSJ9XX19")), "predefinedScalingMetricSpecification") unless @predefined_scaling_metric_specification.nil?
end

Instance Attribute Details

#customized_capacity_metric_specificationAWSCDK::IResolvable, ... (readonly)

The customized capacity metric specification.



1347
1348
1349
# File 'autoscaling/cfn_scaling_policy.rb', line 1347

def customized_capacity_metric_specification
  @customized_capacity_metric_specification
end

#customized_load_metric_specificationAWSCDK::IResolvable, ... (readonly)

The customized load metric specification.



1352
1353
1354
# File 'autoscaling/cfn_scaling_policy.rb', line 1352

def customized_load_metric_specification
  @customized_load_metric_specification
end

#customized_scaling_metric_specificationAWSCDK::IResolvable, ... (readonly)

The customized scaling metric specification.



1357
1358
1359
# File 'autoscaling/cfn_scaling_policy.rb', line 1357

def customized_scaling_metric_specification
  @customized_scaling_metric_specification
end

#predefined_load_metric_specificationAWSCDK::IResolvable, ... (readonly)

The predefined load metric specification.



1362
1363
1364
# File 'autoscaling/cfn_scaling_policy.rb', line 1362

def predefined_load_metric_specification
  @predefined_load_metric_specification
end

#predefined_metric_pair_specificationAWSCDK::IResolvable, ... (readonly)

The predefined metric pair specification from which Amazon EC2 Auto Scaling determines the appropriate scaling metric and load metric to use.



1367
1368
1369
# File 'autoscaling/cfn_scaling_policy.rb', line 1367

def predefined_metric_pair_specification
  @predefined_metric_pair_specification
end

#predefined_scaling_metric_specificationAWSCDK::IResolvable, ... (readonly)

The predefined scaling metric specification.



1372
1373
1374
# File 'autoscaling/cfn_scaling_policy.rb', line 1372

def predefined_scaling_metric_specification
  @predefined_scaling_metric_specification
end

#target_valueNumeric (readonly)

Specifies the target utilization.

Some metrics are based on a count instead of a percentage, such as the request count for an Application Load Balancer or the number of messages in an SQS queue. If the scaling policy specifies one of these metrics, specify the target utilization as the optimal average request or message count per instance during any one-minute interval.



1342
1343
1344
# File 'autoscaling/cfn_scaling_policy.rb', line 1342

def target_value
  @target_value
end

Class Method Details

.jsii_propertiesObject



1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
# File 'autoscaling/cfn_scaling_policy.rb', line 1374

def self.jsii_properties
  {
    :target_value => "targetValue",
    :customized_capacity_metric_specification => "customizedCapacityMetricSpecification",
    :customized_load_metric_specification => "customizedLoadMetricSpecification",
    :customized_scaling_metric_specification => "customizedScalingMetricSpecification",
    :predefined_load_metric_specification => "predefinedLoadMetricSpecification",
    :predefined_metric_pair_specification => "predefinedMetricPairSpecification",
    :predefined_scaling_metric_specification => "predefinedScalingMetricSpecification",
  }
end

Instance Method Details

#to_jsiiObject



1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
# File 'autoscaling/cfn_scaling_policy.rb', line 1386

def to_jsii
  result = {}
  result.merge!({
    "targetValue" => @target_value,
    "customizedCapacityMetricSpecification" => @customized_capacity_metric_specification,
    "customizedLoadMetricSpecification" => @customized_load_metric_specification,
    "customizedScalingMetricSpecification" => @customized_scaling_metric_specification,
    "predefinedLoadMetricSpecification" => @predefined_load_metric_specification,
    "predefinedMetricPairSpecification" => @predefined_metric_pair_specification,
    "predefinedScalingMetricSpecification" => @predefined_scaling_metric_specification,
  })
  result.compact
end