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

MathExpression in Cloudwatch graphs are fixed to a 5min period #7153

Closed
alexmv opened this issue Apr 3, 2020 · 6 comments
Closed

MathExpression in Cloudwatch graphs are fixed to a 5min period #7153

alexmv opened this issue Apr 3, 2020 · 6 comments
Assignees
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@alexmv
Copy link
Contributor

alexmv commented Apr 3, 2020

When serializing the JSON of MathExpression objects, only the expression is output. If the MathExpression has a period other than 5min (due to being derived, say, from 1m metrics), it gets (incorrectly) rendered with 5min intervals -- because the default period at the graph level is 5min, and the serialized MathExpression doesn't specify one.

Reproduction Steps

from aws_cdk import aws_cloudwatch, aws_elasticloadbalancingv2, core


class Example(core.Construct):
    def __init__(
        self,
        scope: core.Construct,
        id: str,
        target_group: aws_elasticloadbalancingv2.ApplicationTargetGroup,
    ) -> None:
        super().__init__(scope, id)

        metric = aws_cloudwatch.MathExpression(
            expression=f"FILL(something,0)",
            using_metrics={
                "something": target_group.metric_healthy_host_count(
                    statistic="average", period=core.Duration.minutes(1),
                )
            },
            period=core.Duration.minutes(1),
        )

        dashboard = aws_cloudwatch.Dashboard(self, "dashboard")
        dashboard.add_widgets(aws_cloudwatch.GraphWidget(left=[metric], width=24))

Screen Shot 2020-04-02 at 6 17 59 PM
(Note 5-min intervals on the datapoints)

Error Log

N/A

Environment

  • CLI Version: 1.17.13
  • Framework Version: 1.31.0
  • OS: OS X 10.14.6
  • Language: Python 3.8.0

Other


This is 🐛 Bug Report

@alexmv alexmv added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 3, 2020
@SomayaB SomayaB added the @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch label Jun 18, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Jun 19, 2020

Works as intended. Specify the intended duration on the MathExpression, not on its compound metrics.

@rix0rrr rix0rrr closed this as completed Jun 19, 2020
@alexmv
Copy link
Contributor Author

alexmv commented Jun 19, 2020

The fifth line from the end specifies the desired period, as part of the MathExpression. Can you be more specific where else the period should be supplied?

@alexmv
Copy link
Contributor Author

alexmv commented Jun 20, 2020

Works as intended. Specify the intended duration on the MathExpression, not on its compound metrics.

I believe that's what the code I showed does:

        metric = aws_cloudwatch.MathExpression(
            # ...
            period=core.Duration.minutes(1),
        )

If you meant something else, please clarify.

@alexmv
Copy link
Contributor Author

alexmv commented Jun 22, 2020

@rix0rrr: Am I misunderstanding your comment, or was this issue closed in error?

@zhy2002
Copy link

zhy2002 commented Jan 27, 2021

This problem still exists as of CDK 1.85.0

@bentonkribbs
Copy link

Looks like this issue has been fixed: #13078

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. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

5 participants