feat(cloudwatch): construct for alarms based on anomaly detection (#10540)#29594
feat(cloudwatch): construct for alarms based on anomaly detection (#10540)#29594
Conversation
aws-cdk-automation
left a comment
There was a problem hiding this comment.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
a90de74 to
b2fbb31
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
comcalvi
left a comment
There was a problem hiding this comment.
Why is there no CfnAnomalyDetector in this construct? Can you help me understand how this works? I thought the AnomalyDetectorAlarm required a reference to the metric of an AnomalyDetector
| public static fromAlarmName(scope: Construct, id: string, alarmName: string): IAlarm { | ||
| const stack = Stack.of(scope); | ||
|
|
||
| return this.fromAlarmArn(scope, id, stack.formatArn({ | ||
| service: 'cloudwatch', | ||
| resource: 'alarm', | ||
| resourceName: alarmName, |
There was a problem hiding this comment.
could we move these from methods out of the Base class? These methods should always be named fromXyzArn or fromXyzName, where Xyz is the name of the construct; Alarm, for example, but also fromAnomalyDetectionAlarm
| /** | ||
| * Properties for Anomaly Detection Alarms | ||
| */ | ||
| export interface AnomalyDetectionAlarmProps extends AlarmProps { |
There was a problem hiding this comment.
The AnomalyDetectionAlarmProps extend the AlarmProps, but the AnomalyDetectionAlarm does not extend Alarm.
Why is the AnomalyDetectionAlarm a separate construct? It looks like it's a strict superset of the Alarm we have already, which suggests that instead of making a new construct we could add a prop to Alarm.
To make this decision we have to understand what the differences between an AnomalyDetectionAlarm and an Alarm are. Are there any properties unique to the AnomalyDetectionAlarm which conflict with the props of a regular Alarm? (Props 'A' and 'B' are said to conflict if I can (or should) specify 'A' or 'B', but not both).
|
This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
|
This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error. |
feat(cloudwatch): construct for alarms based on anomaly detection (#10540)
Issue # (if applicable)
Closes #10540.
Reason for this change
Introduce new construct
AnomalyDetectionAlarmthat covers the gap of creating anAlarmbased on anomaly detection.Description of changes
AnomalyDetectionAlarmAnomalyDetectionAlarmthat creates an alarm that utilizes [CloudWatch anomaly detection](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Anomaly_Detection.htmlAWS::CloudWatch::Alarmmetricproperty has anANOMALY_DETECTION_BANDmetric expression or can generate it. The user can provide thegenerateAnomalyDetectionExpressionproperty to define this behavior.ComparisonOperatorprovided applies to the anomaly detection scenario.thresholdMetricIdwas not exposed to the user because theIMetricinterface does not provide a property to define the id of the metric. This is done when defining theMetricDataQueryProperty; decided to not force the user to provide the array ofMetricDataQueryProperty.thresholdproperty is mandatory by theCreateAlarmOptions. It was repurposed to define the anomaly detection threshold if the function generates theANOMALY_DETECTION_BANDmetric expression.renderMetric()verifies the expressions provided are correct and forces the appropriate reference ids to be in place.fromAlarmName()andfromAlarmArn()were the same forAlarmandCompositeAlarmso moved the to theAlarmBaseso all of the classes can access them.Description of how you validated changes
Integration test and Unit tests and have been added for the
AnomalyDetectionAlarm. Verified the existing tests for theAlarmandCompositeAlarmare not impacted.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license