-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(cloudwatch): add search expression to graph widget in cloudwatch dashboard #34933
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): add search expression to graph widget in cloudwatch dashboard #34933
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.
(This review is outdated)
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
|
Comments on closed issues and PRs are hard for our team to see. |
Abogical
left a comment
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.
Thank you! Some changes are needed.
| withSearchExpression(_searchExpr, _conf) { | ||
| throw new UnscopedValidationError('Search expressions are not supported in CloudWatch Alarms. Use search expressions only in dashboard graphs.'); |
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.
You can use a scoped Validation Error in this context with the scope of the Alarm.
| 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.'); |
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.
Scoped validation error here as well.
| withMathExpression(mathExpr) { | ||
| applyExpressionOptions(mathExpr); | ||
| }, | ||
| withSearchExpression(searchExpr) { | ||
| applyExpressionOptions(searchExpr); |
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.
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.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Abogical
left a comment
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.
Thank you!
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