aws / aws/aws-cdk

aws_cloudwatch: Alarm dimensions support

Open
#29,068 4 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/aws-cloudwatch feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

It is currently not possible to add dimensions to the [Alarm](https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_cloudwatch/Alarm.html) construct while it is possible to do so using [CfnAlarm](https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_cloudwatch/CfnAlarm.html). 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

```ts
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.