-
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
Merged
mergify
merged 26 commits into
aws:main
from
abidhasan-aws:add-search-expression-to-cloudwatch-graph-widget
Jul 17, 2025
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
fec98fe
add search expression to graph widget in cloudwatch dashboard
33b37b7
update comments and small refactors
3982361
add search expression in cloudwatch readme
dd11bfc
remove code duplication and handle search expression properly
2006ab7
add search expression unit tests
d30a120
refactor unit tests
6131651
add integ test for search expression
d6c846f
fix lint issue
3b8183d
add integ test snapshot
20674d4
fix issue with double declaration
ee3afe0
fix documentation & refactor
963db70
refactor unit tests
5265b2b
refactor integ test
7e340e2
refactor integ test
af3df16
integ snapshot update
1298591
add dummy change to trigger pipeline
bf4a2d0
fix failing tests
8e525fd
fix lint
3ba441a
Merge branch 'main' into add-search-expression-to-cloudwatch-graph-wi…
abidhasan-aws 6d653e6
add toString() for search expression
d826ad9
update snapshot for search-expression integ-test
e5b4e7e
add scoped error
bee54ab
Revert "add scoped error"
ec7e001
refactor rendering functions
e72d40c
add scope validation error
0d1d4f9
Merge branch 'main' into add-search-expression-to-cloudwatch-graph-wi…
abidhasan-aws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import { dispatchMetric, metricPeriod } from './private/metric-util'; | |
| import { dropUndefined } from './private/object'; | ||
| import { MetricSet } from './private/rendering'; | ||
| import { normalizeStatistic, parseStatistic } from './private/statistic'; | ||
| import { ArnFormat, Lazy, Stack, Token, Annotations, ValidationError, AssumptionError } from '../../core'; | ||
| import { ArnFormat, Lazy, Stack, Token, Annotations, ValidationError, AssumptionError, UnscopedValidationError } from '../../core'; | ||
| import { addConstructMetadata, MethodMetadata } from '../../core/lib/metadata-resource'; | ||
| import { propertyInjectable } from '../../core/lib/prop-injectable'; | ||
|
|
||
|
|
@@ -475,7 +475,7 @@ export class Alarm extends AlarmBase { | |
| }; | ||
| }, | ||
|
|
||
| withExpression() { | ||
| withMathExpression() { | ||
| // Expand the math expression metric into a set | ||
| const mset = new MetricSet<boolean>(); | ||
| mset.addTopLevel(true, metric); | ||
|
|
@@ -517,7 +517,7 @@ export class Alarm extends AlarmBase { | |
| returnData, | ||
| }; | ||
| }, | ||
| withExpression(expr, conf) { | ||
| withMathExpression(expr, conf) { | ||
| const hasSubmetrics = mathExprHasSubmetrics(expr); | ||
|
|
||
| if (hasSubmetrics) { | ||
|
|
@@ -534,6 +534,9 @@ export class Alarm extends AlarmBase { | |
| returnData, | ||
| }; | ||
| }, | ||
| withSearchExpression(_searchExpr, _conf) { | ||
| throw new UnscopedValidationError('Search expressions are not supported in CloudWatch Alarms. Use search expressions only in dashboard graphs.'); | ||
| }, | ||
| }); | ||
| }), | ||
| } satisfies AlarmMetricFields; | ||
|
|
@@ -544,6 +547,9 @@ export class Alarm extends AlarmBase { | |
|
|
||
| return { props, primaryId }; | ||
| }, | ||
| withSearchExpression() { | ||
| throw new UnscopedValidationError('Search expressions are not supported in CloudWatch Alarms. Use search expressions only in dashboard graphs.'); | ||
|
||
| }, | ||
| }); | ||
| } | ||
|
|
||
|
|
@@ -608,10 +614,14 @@ function isAnomalyDetectionMetric(metric: IMetric): boolean { | |
| // Not an anomaly detection metric | ||
| isAnomalyDetection = false; | ||
| }, | ||
| withExpression(expr) { | ||
| withMathExpression(expr) { | ||
| // Check if the expression is an anomaly detection band | ||
| isAnomalyDetection = expr.expression.includes('ANOMALY_DETECTION_BAND'); | ||
| }, | ||
| withSearchExpression() { | ||
| // Search expressions are not anomaly detection metrics | ||
| isAnomalyDetection = false; | ||
| }, | ||
| }); | ||
|
|
||
| return isAnomalyDetection; | ||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.