Skip to content

cloudwatch: CDK detects false-positive missing identifiers on metric expressions #33591

@garciparedes

Description

@garciparedes

Describe the bug

I have a metric expression defined as SUM(METRICS("prefix")) where some of my metrics contains the "prefix" string.

When I synthetize the CDK, I started getting warning like this:

[Warning at $SECRET Math expression 'SUM(METRICS("prefix"))' references unknown identifiers: prefix. Please add them to the 'usingMetrics' map. [ack: CloudWatch:Math:UnknownIdentifier]

However, those are false-positives and should be skipped in the following line:

if (!this.expression.toUpperCase().match('\\s*INSIGHT_RULE_METRIC|SELECT|SEARCH|METRICS\\s.*') && missingIdentifiers.length > 0) {

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

Given that the METRICS operation accept part identifier names, it should not produce any warnings.

Current Behavior

It produces warnings.

Reproduction Steps

Partially define a identifier in a SUM(METRICS("partial")) expression.

Possible Solution

Update regular expression to properly handle the keywords that skip the warning:

'\\b(INSIGHT_RULE_METRIC|SELECT|SEARCH|METRICS)\\b'

Additional Information/Context

No response

CDK CLI Version

2.173.4

Framework Version

No response

Node.js Version

18

OS

OS X

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions