Skip to content
v2.278.0

TargetTrackingConfigurationProperty Struct ​

TargetTrackingConfiguration is a property of the AWS::AutoScaling::ScalingPolicy resource that specifies a target tracking scaling policy configuration for Amazon EC2 Auto Scaling.

For more information about scaling policies, see Dynamic scaling in the Amazon EC2 Auto Scaling User Guide .

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_autoscaling as autoscaling } from 'aws-cdk-lib';
const targetTrackingConfigurationProperty: autoscaling.CfnScalingPolicy.TargetTrackingConfigurationProperty = {
  targetValue: 123,

  // the properties below are optional
  customizedMetricSpecification: {
    dimensions: [{
      name: 'name',
      value: 'value',
    }],
    metricName: 'metricName',
    metrics: [{
      id: 'id',

      // the properties below are optional
      expression: 'expression',
      label: 'label',
      metricStat: {
        metric: {
          metricName: 'metricName',
          namespace: 'namespace',

          // the properties below are optional
          dimensions: [{
            name: 'name',
            value: 'value',
          }],
        },
        stat: 'stat',

        // the properties below are optional
        period: 123,
        unit: 'unit',
      },
      period: 123,
      returnData: false,
    }],
    namespace: 'namespace',
    period: 123,
    statistic: 'statistic',
    unit: 'unit',
  },
  disableScaleIn: false,
  predefinedMetricSpecification: {
    predefinedMetricType: 'predefinedMetricType',

    // the properties below are optional
    resourceLabel: 'resourceLabel',
  },
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_autoscaling as autoscaling

target_tracking_configuration_property = autoscaling.CfnScalingPolicy.TargetTrackingConfigurationProperty(
    target_value=123,

    # the properties below are optional
    customized_metric_specification=autoscaling.CfnScalingPolicy.CustomizedMetricSpecificationProperty(
        dimensions=[autoscaling.CfnScalingPolicy.MetricDimensionProperty(
            name="name",
            value="value"
        )],
        metric_name="metricName",
        metrics=[autoscaling.CfnScalingPolicy.TargetTrackingMetricDataQueryProperty(
            id="id",

            # the properties below are optional
            expression="expression",
            label="label",
            metric_stat=autoscaling.CfnScalingPolicy.TargetTrackingMetricStatProperty(
                metric=autoscaling.CfnScalingPolicy.MetricProperty(
                    metric_name="metricName",
                    namespace="namespace",

                    # the properties below are optional
                    dimensions=[autoscaling.CfnScalingPolicy.MetricDimensionProperty(
                        name="name",
                        value="value"
                    )]
                ),
                stat="stat",

                # the properties below are optional
                period=123,
                unit="unit"
            ),
            period=123,
            return_data=False
        )],
        namespace="namespace",
        period=123,
        statistic="statistic",
        unit="unit"
    ),
    disable_scale_in=False,
    predefined_metric_specification=autoscaling.CfnScalingPolicy.PredefinedMetricSpecificationProperty(
        predefined_metric_type="predefinedMetricType",

        # the properties below are optional
        resource_label="resourceLabel"
    )
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.autoscaling.*;

TargetTrackingConfigurationProperty targetTrackingConfigurationProperty = TargetTrackingConfigurationProperty.builder()
        .targetValue(123)

        // the properties below are optional
        .customizedMetricSpecification(CustomizedMetricSpecificationProperty.builder()
                .dimensions(List.of(MetricDimensionProperty.builder()
                        .name("name")
                        .value("value")
                        .build()))
                .metricName("metricName")
                .metrics(List.of(TargetTrackingMetricDataQueryProperty.builder()
                        .id("id")

                        // the properties below are optional
                        .expression("expression")
                        .label("label")
                        .metricStat(TargetTrackingMetricStatProperty.builder()
                                .metric(MetricProperty.builder()
                                        .metricName("metricName")
                                        .namespace("namespace")

                                        // the properties below are optional
                                        .dimensions(List.of(MetricDimensionProperty.builder()
                                                .name("name")
                                                .value("value")
                                                .build()))
                                        .build())
                                .stat("stat")

                                // the properties below are optional
                                .period(123)
                                .unit("unit")
                                .build())
                        .period(123)
                        .returnData(false)
                        .build()))
                .namespace("namespace")
                .period(123)
                .statistic("statistic")
                .unit("unit")
                .build())
        .disableScaleIn(false)
        .predefinedMetricSpecification(PredefinedMetricSpecificationProperty.builder()
                .predefinedMetricType("predefinedMetricType")

                // the properties below are optional
                .resourceLabel("resourceLabel")
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.AutoScaling;

var targetTrackingConfigurationProperty = new TargetTrackingConfigurationProperty {
    TargetValue = 123,

    // the properties below are optional
    CustomizedMetricSpecification = new CustomizedMetricSpecificationProperty {
        Dimensions = new [] { new MetricDimensionProperty {
            Name = "name",
            Value = "value"
        } },
        MetricName = "metricName",
        Metrics = new [] { new TargetTrackingMetricDataQueryProperty {
            Id = "id",

            // the properties below are optional
            Expression = "expression",
            Label = "label",
            MetricStat = new TargetTrackingMetricStatProperty {
                Metric = new MetricProperty {
                    MetricName = "metricName",
                    Namespace = "namespace",

                    // the properties below are optional
                    Dimensions = new [] { new MetricDimensionProperty {
                        Name = "name",
                        Value = "value"
                    } }
                },
                Stat = "stat",

                // the properties below are optional
                Period = 123,
                Unit = "unit"
            },
            Period = 123,
            ReturnData = false
        } },
        Namespace = "namespace",
        Period = 123,
        Statistic = "statistic",
        Unit = "unit"
    },
    DisableScaleIn = false,
    PredefinedMetricSpecification = new PredefinedMetricSpecificationProperty {
        PredefinedMetricType = "predefinedMetricType",

        // the properties below are optional
        ResourceLabel = "resourceLabel"
    }
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

targetTrackingConfigurationProperty := &TargetTrackingConfigurationProperty{
	TargetValue: jsii.Number(123),

	// the properties below are optional
	CustomizedMetricSpecification: &CustomizedMetricSpecificationProperty{
		Dimensions: []interface{}{
			&MetricDimensionProperty{
				Name: jsii.String("name"),
				Value: jsii.String("value"),
			},
		},
		MetricName: jsii.String("metricName"),
		Metrics: []interface{}{
			&TargetTrackingMetricDataQueryProperty{
				Id: jsii.String("id"),

				// the properties below are optional
				Expression: jsii.String("expression"),
				Label: jsii.String("label"),
				MetricStat: &TargetTrackingMetricStatProperty{
					Metric: &MetricProperty{
						MetricName: jsii.String("metricName"),
						Namespace: jsii.String("namespace"),

						// the properties below are optional
						Dimensions: []interface{}{
							&MetricDimensionProperty{
								Name: jsii.String("name"),
								Value: jsii.String("value"),
							},
						},
					},
					Stat: jsii.String("stat"),

					// the properties below are optional
					Period: jsii.Number(123),
					Unit: jsii.String("unit"),
				},
				Period: jsii.Number(123),
				ReturnData: jsii.Boolean(false),
			},
		},
		Namespace: jsii.String("namespace"),
		Period: jsii.Number(123),
		Statistic: jsii.String("statistic"),
		Unit: jsii.String("unit"),
	},
	DisableScaleIn: jsii.Boolean(false),
	PredefinedMetricSpecification: &PredefinedMetricSpecificationProperty{
		PredefinedMetricType: jsii.String("predefinedMetricType"),

		// the properties below are optional
		ResourceLabel: jsii.String("resourceLabel"),
	},
}

Properties ​

customizedMetricSpecificationoptionalIResolvable | CfnScalingPolicy.CustomizedMetricSpecificationPropertycustomized_metric_specificationoptionaltyping.Union[IResolvable, CustomizedMetricSpecificationProperty]customizedMetricSpecificationoptionalIResolvableCustomizedMetricSpecificationoptionalIResolvableCustomizedMetricSpecificationoptionalinterface{} #
A customized metric.

You must specify either a predefined metric or a customized metric.

disableScaleInoptionalboolean | IResolvabledisable_scale_inoptionaltyping.Union[bool, IResolvable]disableScaleInoptionalBooleanDisableScaleInoptionalboolDisableScaleInoptionalinterface{} #
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 .

predefinedMetricSpecificationoptionalIResolvable | CfnScalingPolicy.PredefinedMetricSpecificationPropertypredefined_metric_specificationoptionaltyping.Union[IResolvable, PredefinedMetricSpecificationProperty]predefinedMetricSpecificationoptionalIResolvablePredefinedMetricSpecificationoptionalIResolvablePredefinedMetricSpecificationoptionalinterface{} #
A predefined metric.

You must specify either a predefined metric or a customized metric.

targetValuenumbertarget_valueint | floattargetValueNumberTargetValuedoubleTargetValue*float64 required #
The target value for the metric.
notes

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.