Skip to content
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

cloudwatch: expression warning that when e is present in the expression #27932

Closed
tnsardesai opened this issue Nov 10, 2023 · 2 comments
Closed
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@tnsardesai
Copy link

Describe the bug

CDK is displaying a warning thinking e a metric. When using the math expression 'serverError / (success + authError + clientError + serverError + 1e-36)' (to avoid division by zero we are adding 0.000000000000000000000000000000000001)

Expected Behavior

No warning

Current Behavior

[Warning at /IotStack/IoT-Connect-MQTT-ServerError1] Math expression 'serverError / (success + authError + clientError + serverError + 1e-36)' references unknown identifiers: e. Please add them to the 'usingMetrics' map. [ack: CloudWatch:Math:UnknownIdentifier]

Reproduction Steps

Simple error with no metric that always returns 0

const VERY_SMALL_NUMBER = 0.000000000000000000000000000000000001;

const errorRateMetric = new MathExpression({
  label: `Dummy error`,
  expression: `0 / 0 + ${VERY_SMALL_NUMBER})`,
  usingMetrics: {},
  period: Duration.minutes(1),
});

outputs [Warning at /IotStack-production/IoT-PublishOut-MQTT-AuthError4] Math expression '0 / 0 + 1e-36)' references unknown identifiers: e. Please add them to the 'usingMetrics' map. [ack: CloudWatch:Math:UnknownIdentifier]

Possible Solution

In https://github.com/ParkerVR/aws-cdk/blob/5daa6480fa2ebd8bfb2407d80b8df40c367ef8fd/packages/%40aws-cdk/aws-cloudwatch/lib/metric.ts#L749-L754 if identifier is e then it should be considered valid.

This function is used https://github.com/ParkerVR/aws-cdk/blob/5daa6480fa2ebd8bfb2407d80b8df40c367ef8fd/packages/%40aws-cdk/aws-cloudwatch/lib/metric.ts#L610 to give the warning

Additional Information/Context

No response

CDK CLI Version

2.105.0 (build 04cb52d)

Framework Version

No response

Node.js Version

v18.18.0

OS

macOS

Language

TypeScript

Language Version

No response

Other information

No response

@tnsardesai tnsardesai added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 10, 2023
@github-actions github-actions bot added the @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch label Nov 10, 2023
@pahud
Copy link
Contributor

pahud commented Nov 14, 2023

This makes sense to me. Are you able to provide a minimal reproducible cdk app that we can reproduce and see the error messages?

@pahud pahud added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 14, 2023
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants