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: Alarm dimensions support #29068

Open
2 tasks
guidojw opened this issue Feb 11, 2024 · 3 comments
Open
2 tasks

aws_cloudwatch: Alarm dimensions support #29068

guidojw opened this issue Feb 11, 2024 · 3 comments
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch feature-request A feature should be added or improved. p2

Comments

@guidojw
Copy link

guidojw commented Feb 11, 2024

Describe the feature

It is currently not possible to add dimensions to the Alarm construct while it is possible to do so using CfnAlarm. Support for dimensions on the Alarm construct itself would be nice so we don't have to do some lower level magic with the Cfn construct.

Use Case

I have logic that depends on a specific dimension to exist on an alarm.
With alarms based on for example MetricFilters metrics, the metric's dimensions do not propagate to the alarm so I need to set them manually on the alarm. While it is possible with CfnAlarm, this makes it inconvenient because all other alarms are of the Alarm construct and have convenience methods like addAlarmAction, where both the fields are slightly different on CfnAlarm and it does not have these methods.

Proposed Solution

const alarm = new cloudwatch.Alarm(this, 'Errors', {
  comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
  threshold: 1,
  evaluationPeriods: 1,
  metric: alias.metricErrors(),
  dimensions: { Type: 'type' }
});

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

latest

Environment details (OS name and version, etc.)

N/A

@guidojw guidojw added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Feb 11, 2024
@github-actions github-actions bot added the @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch label Feb 11, 2024
@pahud
Copy link
Contributor

pahud commented Feb 13, 2024

We probably can add that in AlarmProps or CreateAlarmOptions.

@pahud pahud added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Feb 13, 2024
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Feb 15, 2024
@guidojw
Copy link
Author

guidojw commented Feb 16, 2024

We probably can add that in AlarmProps or CreateAlarmOptions.

I think it should be CreateAlarmOptions in order for it to work with Metric.createAlarm and in the Alarm constructor.
Then for my application with a MetricFilter-based alarm it is possible to:

new MetricFilter(self, 'MetricFilter', {}).metric({}).createAlarm(self, 'MetricFilterMetricAlarm', {
	dimensions: { key: 'value' }
})

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Feb 16, 2024
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 feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants