Skip to content
v2.278.0

MetricTargetTrackingProps Struct ​

Properties for enabling tracking of an arbitrary metric.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_autoscaling as autoscaling } from 'aws-cdk-lib';
import { aws_cloudwatch as cloudwatch } from 'aws-cdk-lib';

declare const metric: cloudwatch.Metric;
const metricTargetTrackingProps: autoscaling.MetricTargetTrackingProps = {
  metric: metric,
  targetValue: 123,

  // the properties below are optional
  cooldown: cdk.Duration.minutes(30),
  disableScaleIn: false,
  estimatedInstanceWarmup: cdk.Duration.minutes(30),
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_autoscaling as autoscaling
from aws_cdk import aws_cloudwatch as cloudwatch

# metric: cloudwatch.Metric

metric_target_tracking_props = autoscaling.MetricTargetTrackingProps(
    metric=metric,
    target_value=123,

    # the properties below are optional
    cooldown=cdk.Duration.minutes(30),
    disable_scale_in=False,
    estimated_instance_warmup=cdk.Duration.minutes(30)
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.autoscaling.*;
import software.amazon.awscdk.services.cloudwatch.*;

Metric metric;

MetricTargetTrackingProps metricTargetTrackingProps = MetricTargetTrackingProps.builder()
        .metric(metric)
        .targetValue(123)

        // the properties below are optional
        .cooldown(Duration.minutes(30))
        .disableScaleIn(false)
        .estimatedInstanceWarmup(Duration.minutes(30))
        .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;
using Amazon.CDK.AWS.AutoScaling;
using Amazon.CDK.AWS.CloudWatch;

Metric metric;

var metricTargetTrackingProps = new MetricTargetTrackingProps {
    Metric = metric,
    TargetValue = 123,

    // the properties below are optional
    Cooldown = Duration.Minutes(30),
    DisableScaleIn = false,
    EstimatedInstanceWarmup = Duration.Minutes(30)
};
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"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var metric Metric

metricTargetTrackingProps := &MetricTargetTrackingProps{
	Metric: metric,
	TargetValue: jsii.Number(123),

	// the properties below are optional
	Cooldown: cdk.Duration_Minutes(jsii.Number(30)),
	DisableScaleIn: jsii.Boolean(false),
	EstimatedInstanceWarmup: cdk.Duration_*Minutes(jsii.Number(30)),
}

Properties ​

cooldownoptionalDurationcooldownoptionalDurationcooldownoptionalDurationCooldownoptionalDurationCooldownoptionalDuration #
Period after a scaling completes before another scaling activity can start.

Default: The default cooldown configured on the AutoScalingGroup.

disableScaleInoptionalbooleandisable_scale_inoptionalbooldisableScaleInoptionalBooleanDisableScaleInoptionalboolDisableScaleInoptional*bool = false #
Indicates whether scale in by the target tracking policy is disabled.

If the value is true, scale in is disabled and the target tracking policy won't remove capacity from the autoscaling group. Otherwise, scale in is enabled and the target tracking policy can remove capacity from the group.

estimatedInstanceWarmupoptionalDurationestimated_instance_warmupoptionalDurationestimatedInstanceWarmupoptionalDurationEstimatedInstanceWarmupoptionalDurationEstimatedInstanceWarmupoptionalDuration #
Estimated time until a newly launched instance can send metrics to CloudWatch.

Default: Same as the cooldown.

metricIMetricmetricIMetricmetricIMetricMetricIMetricMetricIMetric required #
Metric to track.

The metric must represent a utilization, so that if it's higher than the target value, your ASG should scale out, and if it's lower it should scale in.

targetValuenumbertarget_valueint | floattargetValueNumberTargetValuedoubleTargetValue*float64 required #
Value to keep the metric around.