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] The period of a MathExpression is not respected on CloudWatch #9156

Closed
jrmcornish opened this issue Jul 18, 2020 · 2 comments · Fixed by #13078
Closed

[aws-cloudwatch] The period of a MathExpression is not respected on CloudWatch #9156

jrmcornish opened this issue Jul 18, 2020 · 2 comments · Fixed by #13078
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 p1

Comments

@jrmcornish
Copy link

The period of a MathExpression CloudWatch metric that is used in a GraphWidget is currently not respected. In particular, it is possible to specify a period of 1 minute, but for data points still to be spaced every 5 minutes.

Reproduction Steps

Assume below that queue is some aws_sqs.Queue, and dashboard is some aws_cloudwatch.Dashboard. Then consider the following:

metric = queue.metric_approximate_number_of_messages_visible()

dashboard.add_widgets(
    aws_cloudwatch.GraphWidget(
        left=[
            aws_cloudwatch.MathExpression(
                expression=f"2 * x",
                using_metrics={"x": metric},
                period=core.Duration.minutes(1)
            )
        ]
    )
)

In CloudWatch, this produces a widget showing data points every 5 minutes, rather than every 1 minute as expected.

Error Log

The actual JSON produced for the widget above will be similar to the following (apart from QueueName and region changes):

{
    "view": "timeSeries",
    "region": "us-east-1",
    "metrics": [
        [ { "label": "2 * x", "expression": "2 * x", "region": "us-east-1" } ],
        [ "AWS/SQS", "ApproximateNumberOfMessagesVisible", "QueueName", "MY_QUEUE_NAME", { "period": 60, "stat": "Maximum", "visible": false, "id": "x" } ]
    ],
    "period": 300
}

This corresponds to showing measurements spaced every 5 minutes by default.

If the first metrics item in the dictionary above is replaced with

        [ { "label": "2 * x", "expression": "2 * x", "region": "us-east-1", "period": 60 } ],

then data points are spaced correctly every 1 minute. However, the code produced by the CDK does not generate this.

Environment

  • CLI Version : aws-cli/1.18.8 Python/3.7.4 Linux/5.3.0-62-generic botocore/1.15.8
  • Framework Version: 1.45.0 (build 0cfab15)
  • Node.js Version: v10.16.3
  • OS : Linux 5.3.0-62-generic #56~18.04.1-Ubuntu SMP Wed Jun 24 16:17:03 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Language (Version): Python 3.7.4

Other


This is 🐛 Bug Report

@jrmcornish jrmcornish added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 18, 2020
@github-actions github-actions bot added the @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch label Jul 18, 2020
@ericzbeard ericzbeard removed the needs-triage This issue or PR still needs to be triaged. label Jul 20, 2020
@ericzbeard ericzbeard removed their assignment Aug 3, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Aug 4, 2020

Well we completely generated it like this on purpose, where the math expression would get rendered at the resolution of the underlying metrics. I remember testing this, and I wonder if CloudWatch changed its behavior here.

The fix is probably to always emit a period for the math expression.

@rix0rrr rix0rrr added effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p1 labels Aug 4, 2020
@mergify mergify bot closed this as completed in #13078 Feb 25, 2021
mergify bot pushed a commit that referenced this issue Feb 25, 2021
…#13078)

fixes #9156

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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 p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants