We would like to autoscale based on SQS size.
I was able to follow the below link and add custom autoscaling policy across the auto scaling group.
{
"CustomizedMetricSpecification": {
"Metrics": [
{
"Label": "Get the queue size (the number of messages waiting to be processed)",
"Id": "m1",
"MetricStat": {
"Metric": {
"MetricName": "ApproximateNumberOfMessagesVisible",
"Namespace": "AWS/SQS",
"Dimensions": [
{
"Name": "QueueName",
"Value": "my-queue"
}
]
},
"Stat": "Sum"
},
"ReturnData": false
},
{
"Label": "Get the group size (the number of InService instances)",
"Id": "m2",
"MetricStat": {
"Metric": {
"MetricName": "GroupInServiceInstances",
"Namespace": "AWS/AutoScaling",
"Dimensions": [
{
"Name": "AutoScalingGroupName",
"Value": "my-asg"
}
]
},
"Stat": "Average"
},
"ReturnData": false
},
{
"Label": "Calculate the backlog per instance",
"Id": "e1",
"Expression": "m1 / m2",
"ReturnData": true
}
]
},
"TargetValue": 100
}
After execution of this snippet, I see two alarms one for scale in and another for scale out.
Question: Will the above step also publish metric data to Cloudwatch? Because I don't see metric data populating which means no scaling is happening.