Skip to content

cloudwatch metrics: expression warning too simplistic #20136

@robjongbloed

Description

@robjongbloed

Describe the bug

CDK displays a warning for metrics expressions that are valid.

Specifically, it is trying to check that all variables used in the expression are defined, bit it does not deal with the SEARCH function, and likely not the METRICS either.

Expected Behavior

Not display a warning for valid expressions.

Current Behavior

Warning at /realtime-chime-meeting-local-997654549727-us-east-1-rjongbloed/Mon/Dash] Math expression '100 * SEARCH('{AWS/ApiGateway,ApiName,Method,Resource,Stage} ApiName=my-api MetricName=("4XXError" OR "5XXError")', 'Average', 60)' references unknown identifiers: piGateway, piName, ethod, esource, tage, piName, realtime, chime, meeting, local, rjongbloed, etricName, rror, rror, verage. Please add them to the 'usingMetrics' map.

Reproduction Steps

Create a metric using SEARCH function.

Possible Solution

  • Parse the complex expression including functions, quotes, parentheses etc.
  • Don't do the check if the expression has "SEARCH" or "METRICS" in it.
  • Remove the warning completely.

Additional Information/Context

No response

CDK CLI Version

2.22.0 (build 1db4b16)

Framework Version

1.153.1

Node.js Version

v16.15.0

OS

MacOS

Language

Typescript, Python

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-cloudwatchRelated to Amazon CloudWatchbugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions