aws-cdk
aws-cdk copied to clipboard
fix(cloudwatch): support the creation of CloudWatch anomaly detection alarm
Issue #10540
Closes #10540.
Reason for this change
This change add the possibility to create an anomaly detection alarm based on a Metric or MathExpression object.
Description of changes
Creation of a helper function in Metric or MathExpression classes which will wrap the actual metric into an anomaly detection metric expression before creating the CloudWatch alarm.
This PR also include a refactor of the CreateAlarmOptions class in order to reflect the incompatibilities between standard alarm and anomaly detection ones.
Description of how you validated changes
Executed the new integration test (packages/@aws-cdk-testing/framework-integ/test/aws-cloudwatch/test/integ.anomaly-detection-alarm.ts) on a test account.
Checklist
- [X] My code adheres to the CONTRIBUTING GUIDE and DESIGN GUIDELINES
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
General question: There's a CfnAnomalyDetector L1 construct which is not used here. Could you help me understand the diff between CfnAnomalyDetector and what we are achieving in this PR?
@scorbiere are you still working on this PR or should we close it for now? I'm going to close this since this seems abandonded. Feel free to re-open this if you're planning to work on this.
Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.
General question: There's a
CfnAnomalyDetectorL1 construct which is not used here. Could you help me understand the diff betweenCfnAnomalyDetectorand what we are achieving in this PR?
CfnAnomalyDetector and this implementation serve different purposes in the CloudWatch ecosystem:
CfnAnomalyDetector (L1 Construct):
- Creates a standalone anomaly detector resource in CloudWatch
- Is primarily designed for anomaly detection visualization and monitoring, not specifically for alarms
- Represents the
AWS::CloudWatch::AnomalyDetectorCloudFormation resource - Does not directly integrate with CloudWatch Alarms without additional configuration
- Useful for creating anomaly detection bands that can be visualized in dashboards or queried via API
This Implementation (Using ANOMALY_DETECTION_BAND):
- Specifically designed for creating CloudWatch Alarms based on anomaly detection
- Uses CloudWatch's built-in anomaly detection capabilities via metric math expressions
- Creates an alarm that directly incorporates anomaly detection without requiring a separate detector resource
- Automatically configures the required thresholdMetricId property needed for alarms
- Handles all the complexity required to make anomaly detection work with alarms
The fundamental difference is that CfnAnomalyDetector is not designed specifically for alarm scenarios, while this implementation is purpose-built for creating anomaly detection alarms. The CfnAnomalyDetector creates a standalone resource that can be used for visualization and analysis, but requires additional configuration to be used with alarms.
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).
This pull request has been removed from the queue for the following reason: pull request branch update failed.
The pull request can't be updated.
You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.
AWS CodeBuild CI Report
- CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
- Commit ID: 35ad3174fb6c1a85ed7a11b7aae5202d74bdd95e
- Result: SUCCEEDED
- Build Logs (available for 30 days)
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).
Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.