Ecs target tracking autoscaling based on custom metric

Hi,

Does localstack support ecs autoscaling using target tracking on a custom metric? I’ve been struggling all day to get it to work, but not having any luck.

aws ecs list-clusters --profile localstack --region us-east-1:

{
    "clusterArns": [
        "arn:aws:ecs:us-east-1:000000000000:cluster/cluster1"
    ]
}

aws cloudwatch list-metrics --profile localstack (snipped for brevity):

 {
            "Namespace": "AutoScale/ECS/SQS",
            "MetricName": "BacklogPerTask",
            "Dimensions": [
                {
                    "Name": "ClusterName",
                    "Value": "cluster1"
                },
                {
                    "Name": "ServiceName",
                    "Value": "ecs-consumer-2"
                }
            ]
        },

aws ecs list-services --cluster arn:aws:ecs:us-east-1:000000000000:cluster/cluster1 --profile localstack:

{
    "serviceArns": [
        "arn:aws:ecs:us-east-1:000000000000:service/cluster1/ecs-consumer",
        "arn:aws:ecs:us-east-1:000000000000:service/cluster1/ecs-consumer-2",
        "arn:aws:ecs:us-east-1:000000000000:service/cluster1/producer_service"
    ]
}

aws application-autoscaling describe-scaling-policies --service-namespace ecs --profile localstack (snipped for brevity):

{
            "PolicyARN": "arn:aws:autoscaling:us-east-1:000000000000:scalingPolicy:9c79fdb4-3f1b-4997-8fed-d876ea943009:resource/ecs/service/cluster1/ecs-consumer-2:policyName/ecs-consumer-2-scaling-policy",
            "PolicyName": "ecs-consumer-2-scaling-policy",
            "ServiceNamespace": "ecs",
            "ResourceId": "service/cluster1/ecs-consumer-2",
            "ScalableDimension": "ecs:service:DesiredCount",
            "PolicyType": "TargetTrackingScaling",
            "TargetTrackingScalingPolicyConfiguration": {
                "TargetValue": 20,
                "CustomizedMetricSpecification": {
                    "MetricName": "BacklogPerTask",
                    "Namespace": "AutoScale/ECS/SQS",
                    "Dimensions": [
                        {
                            "Name": "ServiceName",
                            "Value": "ecs-consumer-2"
                        },
                        {
                            "Name": "ClusterName",
                            "Value": "cluster1"
                        }
                    ],
                    "Statistic": "SampleCount",
                    "Unit": "Count"
                },
                "ScaleOutCooldown": 60,
                "ScaleInCooldown": 60,
                "DisableScaleIn": false
            },
            "Alarms": [
                {
                    "AlarmName": "TargetTracking-service/cluster1/ecs-consumer-2-AlarmHigh-ab4a6ef0-67e0-4883-95a5-da3d486253df",
                    "AlarmARN": "arn:aws:cloudwatch:us-east-1:000000000000:alarm:TargetTracking-service/cluster1/ecs-consumer-2-AlarmHigh-ab4a6ef0-67e0-4883-95a5-da3d486253df"
                },
                {
                    "AlarmName": "TargetTracking-service/cluster1/ecs-consumer-2-AlarmLow-4866358f-7690-4ed4-9cc5-b43d18b2db4a",
                    "AlarmARN": "arn:aws:cloudwatch:us-east-1:000000000000:alarm:TargetTracking-service/cluster1/ecs-consumer-2-AlarmLow-4866358f-7690-4ed4-9cc5-b43d18b2db4a"
                }
            ],
            "CreationTime": "2024-08-15T15:16:34.186736-07:00"
        },

Am I missing something, or have something misconfigured in my scaling policy?

Hello @conejo,

Please follow the steps in Application Auto Scaling | Docs (localstack.cloud) and see if the proposed sample works for you.

The following operations are supported in LocalStack Application Auto Scaling | Docs (localstack.cloud).

We will investigate the ECS use case.