aws / aws/aws-cdk

aws_applicationautoscaling: Error: Only direct metrics are supported for Target Tracking. Use Step Scaling or supply a Metric object.

Open
#20,659 14 comments 26 reactions 0 assignees View on GitHub
@aws-cdk/aws-applicationautoscaling bug needs-cfn p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

I would like to use a `MathExpression` for custom metric in `TargetTrackingScalingPolicy`, but I got this error:
> Only direct metrics are supported for Target Tracking. Use Step Scaling or supply a Metric object.

checking the code [here](https://github.com/aws/aws-cdk/blob/v1-main/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts#L133), it only checks for `metricStat` not `mathExpression`.

### 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_

Contributor guide

Open the contributing guide

Research direction

Read packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts around line 133, where the implementation checks metricStat but not mathExpression. Reproduce a TargetTrackingScalingPolicy using a MathExpression and verify the AWS Target Tracking requirements. Done means valid MathExpression metrics are accepted without the direct-metric error and the existing behavior for direct metrics remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.