New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws_applicationautoscaling: Error: Only direct metrics are supported for Target Tracking. Use Step Scaling or supply a Metric object. #20659
Comments
I also tried to create a metric this way:
and use it in
|
These properties are directly passed to the ScalingPolicy CloudFormation resource in this property. Our |
Also encountering this issue |
It seems like CloudFormation's AWS::AutoScaling::ScalingPolicy is indeed lacking some configuration parameters. The |
It looks like AWS announced support for this recently: https://www.amazonaws.cn/en/new/2023/application-auto-scaling-supports-metric-math-for-target-tracking-policies/ and the documentation is now available: https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-target-tracking-metric-math.html It would be great to see this feature in CDK too |
As per the second page you link to, "This feature is not yet available in AWS CloudFormation.". So CDK either has to wait for Cloudformation support, or provide this via a custom resource. |
Any updates on this? Or any workarounds via CDK as of now? |
I came across this today whilst folloing the and lost a few hours on it. As a temporary workaround, I've added a custom resource using
You can use it like this:
It may need some adaptations to meet your needs but it should give you a good starting point. I should mention I've not fully tested this yet so if you notice anything weird then please share :) |
@alexbaileyuk Thank you! |
@zubairzahoor due to difficulties with this method I ended up writing a totally different function which pre-calculates backlog / instance by pulling and calculating. Something like this:
It also relies on some tags on the ECS services. It's a bit messy and not well refined at the moment since I'm still testing and working on edge cases like the scale to zero ones. It loops through all services in a cluster and based on their tags and metrics, defines a new metric called I'd advise doing something similar. The main issues came on stack updates. You can't create the scaling policy without defining a name and when defining a name I ended up with tons of issues trying to update/replace/rollback etc. I'd recommend not using the above method for those reasons. |
@alexbaileyuk I am more comfortable using the above, works well for me. Were there any issues you encounted with scaling-in using the custom resource? |
@zubairzahoor we're going to production later in the week with a more refined version of the code. We've not found any major issues so far. |
Very interesting discussion. I managed to fix it with CDK-only syntax. I hope it helps 😉
|
Describe the bug
I would like to use a
MathExpression
for custom metric inTargetTrackingScalingPolicy
, but I got this error:checking the code here, it only checks for
metricStat
notmathExpression
.Expected Behavior
Should allow to define math expression for Target Tracking.
Current Behavior
Only direct metrics are allowed
Reproduction Steps
Create Target Tracking using math expression
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.27.0
Framework Version
No response
Node.js Version
16.15.0
OS
Debian 10
Language
Python
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: