feat(cloudwatch): add search expression to graph widget in cloudwatch dashboard#34933
Merged
mergify[bot] merged 26 commits intoaws:mainfrom Jul 17, 2025
abidhasan-aws:add-search-expression-to-cloudwatch-graph-widget
Merged
feat(cloudwatch): add search expression to graph widget in cloudwatch dashboard#34933mergify[bot] merged 26 commits intoaws:mainfrom abidhasan-aws:add-search-expression-to-cloudwatch-graph-widget
mergify[bot] merged 26 commits intoaws:mainfrom
abidhasan-aws:add-search-expression-to-cloudwatch-graph-widget
Conversation
aws-cdk-automation
previously requested changes
Jul 9, 2025
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
Contributor
|
Comments on closed issues and PRs are hard for our team to see. |
Abogical
requested changes
Jul 16, 2025
Member
Abogical
left a comment
There was a problem hiding this comment.
Thank you! Some changes are needed.
Comment on lines
+537
to
+538
| withSearchExpression(_searchExpr, _conf) { | ||
| throw new UnscopedValidationError('Search expressions are not supported in CloudWatch Alarms. Use search expressions only in dashboard graphs.'); |
Member
There was a problem hiding this comment.
You can use a scoped Validation Error in this context with the scope of the Alarm.
Suggested change
| withSearchExpression(_searchExpr, _conf) { | |
| throw new UnscopedValidationError('Search expressions are not supported in CloudWatch Alarms. Use search expressions only in dashboard graphs.'); | |
| withSearchExpression: (_searchExpr, _conf) => { // Use arrow function to not override `this` from the class instance. | |
| throw new ValidationError('Search expressions are not supported in CloudWatch Alarms. Use search expressions only in dashboard graphs.', this); |
| return { props, primaryId }; | ||
| }, | ||
| withSearchExpression() { | ||
| throw new UnscopedValidationError('Search expressions are not supported in CloudWatch Alarms. Use search expressions only in dashboard graphs.'); |
Member
There was a problem hiding this comment.
Scoped validation error here as well.
Abogical
requested changes
Jul 16, 2025
Comment on lines
+79
to
+83
| withMathExpression(mathExpr) { | ||
| applyExpressionOptions(mathExpr); | ||
| }, | ||
| withSearchExpression(searchExpr) { | ||
| applyExpressionOptions(searchExpr); |
Member
There was a problem hiding this comment.
You can also "hoist" the applyExpressionOptions function for cleaner code.
const applyExpressionOptions = (options: any, exprConfig: MetricExpressionConfig) => {
...
};
function metricGraphJson(metric: IMetric, yAxis?: string, id?: string) {
...
withMathExpression(mathExpr) {
applyExpressionOptions(options, mathExpr);
},
withSearchExpression(searchExpr) {
applyExpressionOptions(options, searchExpr);
This reverts commit e5b4e7e.
Collaborator
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue # (if applicable)
Closes #7237
Reason for this change
Currently,
GraphWidgetonly supportsMathExpressionorMetricobjects. There is no native support forSearchExpression.Although it is possible to use a search expression through a math expression, doing so requires hacky workarounds and additional boilerplate code.
Description of changes
Added
SearchExpressionclass to enable native support for search expression withinGraphWidget.Description of how you validated changes
Added unit tests and integration tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license