Created
December 13, 2022 10:46
-
-
Save andreaswittig/ed7f8e187e6fe1bf41ad6e059d2d402c to your computer and use it in GitHub Desktop.
Auto Scaling: Target Tracking with Metric Math
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws autoscaling put-scaling-policy \ | |
--auto-scaling-group-name ASG_NAME \ | |
--policy-name target-tracking \ | |
--policy-type TargetTrackingScaling \ | |
--target-tracking-configuration file://target-tracking-configuration.json \ | |
--estimated-instance-warmup 300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"CustomizedMetricSpecification": { | |
"Metrics": [ | |
{ | |
"Id": "messages", | |
"MetricStat": { | |
"Metric": { | |
"Namespace": "AWS/SQS", | |
"MetricName": "ApproximateNumberOfMessagesVisible", | |
"Dimensions": [ | |
{ | |
"Name": "QueueName", | |
"Value": "QUEUE_NAME" | |
} | |
] | |
}, | |
"Stat": "Maximum", | |
"Unit": "Count" | |
}, | |
"Label": "Enqueued Messages", | |
"ReturnData": false | |
}, | |
{ | |
"Id": "instances", | |
"MetricStat": { | |
"Metric": { | |
"Namespace": "AWS/AutoScaling", | |
"MetricName": "GroupTotalInstances", | |
"Dimensions": [ | |
{ | |
"Name": "AutoScalingGroupName", | |
"Value": "ASG_NAME" | |
} | |
] | |
}, | |
"Stat": "Maximum", | |
"Unit": "Count" | |
}, | |
"Label": "Instances", | |
"ReturnData": false | |
}, | |
{ | |
"Id": "e1", | |
"Expression": "FILL(instances, 1)", | |
"Label": "E1", | |
"ReturnData": false | |
}, | |
{ | |
"Id": "e2", | |
"Expression": "messages/IF(e1>0, e1, 1)", | |
"Label": "E2", | |
"ReturnData": true | |
} | |
] | |
}, | |
"TargetValue": 0.0001, | |
"DisableScaleIn": false | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment