how to add autoscaling policy to an sagemaker endpoint via terraform?

0

based on the documentation here, https://github.com/aws/amazon-sagemaker-examples/blob/main/async-inference/Async-Inference-Walkthrough.ipynb, an autoscaling policy could be added to an sagemaker async endpoint . I want to set this via terraform and have this so far (sample below) , but i'm not how to set Dimensions attribute in TargetTrackingScalingPolicyConfiguration in terraform?

  TargetTrackingScalingPolicyConfiguration={
        "TargetValue": 5.0, SageMakerVariantInvocationsPerInstance
        "CustomizedMetricSpecification": {
            "MetricName": "ApproximateBacklogSizePerInstance",
            "Namespace": "AWS/SageMaker",
            "Dimensions": [{"Name": "EndpointName", "Value": endpoint_name}],
            "Statistic": "Average",
        },
resource "aws_appautoscaling_target" "sagemaker_target" {
  max_capacity       =  3
  min_capacity       = 1
  resource_id        = "myendpoint"
  scalable_dimension = "sagemaker:variant:DesiredInstanceCount"
  service_namespace  = "sagemaker"
}

resource "aws_appautoscaling_policy" "sagemaker_policy" {
  name               = "somepolicy"
  policy_type        = "TargetTrackingScaling"
  resource_id        = aws_appautoscaling_target.sagemaker_target.resource_id
  scalable_dimension = aws_appautoscaling_target.sagemaker_target.scalable_dimension
  service_namespace  = aws_appautoscaling_target.sagemaker_target.service_namespace

  target_tracking_scaling_policy_configuration {
    customized_metric_specification{
      metric_name = "ApproximateBacklogSizePerInstance"
      namespace =  "AWS/SageMaker"
      Dimensions = ....?????
      statistic =  "Average"
    }
    target_value       = 3
    scale_in_cooldown  =300
    scale_out_cooldown = 600
  }
}


質問済み 2年前604ビュー
1回答
0

Hi,

This Dimensions refer to the CloudWatch dimensions of metric ApproximateBacklogSizePerInstance. It's the same dimension when you first define the metric as described in doc here

AWS
回答済み 2年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ