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

[aws-cloudwatch] Incorrect comparison operator for alarm annotation label #8913

Closed
jebaney opened this issue Jul 6, 2020 · 1 comment · Fixed by #10418
Closed

[aws-cloudwatch] Incorrect comparison operator for alarm annotation label #8913

jebaney opened this issue Jul 6, 2020 · 1 comment · Fixed by #10418
Assignees
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md in-progress This issue is being actively worked on. p2

Comments

@jebaney
Copy link

jebaney commented Jul 6, 2020

Alarm.OPERATOR_SYMBOLS has the incorrect string value for LessThanOrEqualToThreshold. Instead of <= (less than, equal to) it has >= (greater than, equal to).

const OPERATOR_SYMBOLS = {
    GreaterThanOrEqualToThreshold: '>=',
    GreaterThanThreshold: '>',
    LessThanThreshold: '<',
    LessThanOrEqualToThreshold: '>=',   <-- incorrect
};

When the annotation is eagerly created (Alarm Line 201)[https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-cloudwatch/lib/alarm.ts#L201] label: ${this.metric} ${OPERATOR_SYMBOLS[comparisonOperator]} ${props.threshold} for...` the incorrect string value is added to the annotation's label, which causes confusion as to what the alarm is actually doing since it is the exact opposite of what the alarm is doing.

Reproduction Steps

  • create a metric
  • create an alarm with the provided metric and the comparison operator of LessThanOrEqualToThreshold
  • create a graph widget for the metric and add the alarm as an annotation (I used horizontal annotations)
  • Viewing the alarm itself shows the proper monitoring of metric <= threshold
  • Viewing graph widget shows the annotation with incorrect label metric >= threshold

Environment

  • CLI Version cdk 1.23.0 :
  • Framework Version:
  • Node.js Version: 2.0.202680.0 (npm-pretty-much)
  • OS AL2 :
  • Language (Version): "typescript": "^3.6.4" -->

Other

  • Flip the operator from >= to <=

Cloudwatch alarm with the correct condition (so the alarm itself is fine)
alarm_correct_comparison

Cloudwatch graph widget with same alarm as an annotation with incorrect comparison operator
annotation_incorrect_comparison


This is 🐛 Bug Report

@jebaney jebaney added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 6, 2020
@github-actions github-actions bot added the @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch label Jul 6, 2020
@rix0rrr rix0rrr added good first issue Related to contributions. See CONTRIBUTING.md p2 labels Jul 8, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Jul 8, 2020

Thanks for the research and the thorough bug report.

Could I tempt you to turn that research into a PR? :)

@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Jul 8, 2020
@NetaNir NetaNir added the effort/small Small work item – less than a day of effort label Aug 10, 2020
alvyn279 added a commit to alvyn279/aws-cdk that referenced this issue Sep 18, 2020
- Fixed incorrect comparison operator (LTE) string from '>=' to '<='
- fixes aws#8913
@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Sep 18, 2020
@mergify mergify bot closed this as completed in #10418 Sep 21, 2020
mergify bot pushed a commit that referenced this issue Sep 21, 2020
- Fixed incorrect comparison operator (LTE) string from '>=' to '<='
- fixes #8913


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
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. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md in-progress This issue is being actively worked on. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants