Skip to content
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_cloudwatch: Metric class dimensions property limited to 10 items #29322

Closed
ruvimrd opened this issue Feb 29, 2024 · 2 comments · Fixed by #29341
Closed

aws_cloudwatch: Metric class dimensions property limited to 10 items #29322

ruvimrd opened this issue Feb 29, 2024 · 2 comments · Fixed by #29341
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@ruvimrd
Copy link
Contributor

ruvimrd commented Feb 29, 2024

Describe the bug

Property: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.Metric.html#dimensions

CloudFormation allows up to 30 items for the 'dimensions' property as seen here.

Currently CDK limits the items to a maximum amount of 10.
Code with the hard limit: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts#L512-L514

If you need to deploy an Alarm with more than 30 dimensions, the L1 CfnAlarm has to be used.

Expected Behavior

Up to 30 items should be allowed for the dimensions property

Current Behavior

Error thrown: The maximum number of dimensions is 10, received 11

Reproduction Steps

Simple reproduction:

const metric = new cloudwatch.Metric({
  metricName: 'Test',
  namespace: 'namespace',
  dimensionsMap: {
    d1: 'value1',
    d2: 'value2',
    d3: 'value3',
    d4: 'value4',
    d5: 'value5',
    d6: 'value6',
    d7: 'value7',
    d8: 'value8',
    d9: 'value9',
    d10: 'value10',
    // d11: 'value11'
  }
})

const alarm = new cloudwatch.Alarm(this, 'TestAlarm', {
  comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
  threshold: 1,
  evaluationPeriods: 1,
  metric: metric
});

//Uncomment d11 dimension above to get the error

Possible Solution

Change hard limits from 10 to 30 here: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts#L512-L514

Additional Information/Context

No response

CDK CLI Version

2.130.0

Framework Version

No response

Node.js Version

18.19.1

OS

macOS

Language

TypeScript

Language Version

No response

Other information

No response

@ruvimrd ruvimrd added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 29, 2024
@github-actions github-actions bot added the @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch label Feb 29, 2024
@pahud pahud added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Mar 1, 2024
@pahud
Copy link
Contributor

pahud commented Mar 1, 2024

Thank you for the pull request!

@mergify mergify bot closed this as completed in #29341 Mar 1, 2024
mergify bot pushed a commit that referenced this issue Mar 1, 2024
### Issue # (if applicable)

Closes #29322.

### Reason for this change

[AWS::CloudWatch::Alarm](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-alarm.html) allows up to 30 dimension items, while the L2 [construct](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.Metric.html#dimensions) for Metric allows up to 10.

### Description of changes

Increased hard limit from 10 -> 30 

### Description of how you validated changes

Updated unit test, added new integration test

### Checklist
- [X] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy link

github-actions bot commented Mar 1, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

godwingrs22 pushed a commit to godwingrs22/aws-cdk that referenced this issue Mar 1, 2024
### Issue # (if applicable)

Closes aws#29322.

### Reason for this change

[AWS::CloudWatch::Alarm](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-alarm.html) allows up to 30 dimension items, while the L2 [construct](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.Metric.html#dimensions) for Metric allows up to 10.

### Description of changes

Increased hard limit from 10 -> 30 

### Description of how you validated changes

Updated unit test, added new integration test

### Checklist
- [X] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
2 participants