-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(cloudwatch): construct for alarms based on anomaly detection (#10540) #29594
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
AnomalyDetectionAlarm
that covers the gap of creating anAlarm
based on anomaly detection.Description of changes
AnomalyDetectionAlarm
AnomalyDetectionAlarm
that creates an alarm that utilizes [CloudWatch anomaly detection](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Anomaly_Detection.htmlAWS::CloudWatch::Alarm
metric
property has anANOMALY_DETECTION_BAND
metric expression or can generate it. The user can provide thegenerateAnomalyDetectionExpression
property to define this behavior.ComparisonOperator
provided applies to the anomaly detection scenario.thresholdMetricId
was not exposed to the user because theIMetric
interface 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
.threshold
property is mandatory by theCreateAlarmOptions
. It was repurposed to define the anomaly detection threshold if the function generates theANOMALY_DETECTION_BAND
metric expression.renderMetric()
verifies the expressions provided are correct and forces the appropriate reference ids to be in place.fromAlarmName()
andfromAlarmArn()
were the same forAlarm
andCompositeAlarm
so moved the to theAlarmBase
so 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 theAlarm
andCompositeAlarm
are not impacted.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license