question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MathExpression in Cloudwatch graphs are fixed to a 5min period

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bentonkribbscommented, Mar 11, 2021

Looks like this issue has been fixed: https://github.com/aws/aws-cdk/pull/13078

1reaction
alexmvcommented, Jun 22, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using metric math - Amazon CloudWatch
Function Arguments Return type* Supported for cross‑account? ABS TS. TS TS. TS ✓ ANOMALY_DETECTION_BAND TS. TS, S TS AVG TS. TS S. TS ✓
Read more >
Amazon CloudWatch Launches Metric Math - YouTube
Amazon CloudWatch Metric Math enables you to perform calculations across multiple metrics for real- time analysis. You can visualize these ...
Read more >
aws-cdk.aws-cloudwatch - Python Package Health Analysis
... graph showing the Average statistic with an aggregation period of 5 minutes: cpu_utilization = cloudwatch.MathExpression( expression="SEARCH('{AWS/EC2 ...
Read more >
Dashboard Body Structure and Syntax - Amazon CloudWatch
The first includes two metrics and a math expression that sums their total. ... Use this field to specify the period for the...
Read more >
Amazon CloudWatch - User Guide - The IT Infrastructure Report
Adding a Math Expression to a CloudWatch Graph . ... Data points with a period of 300 seconds (5 minute) are available for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found