MathExpression in Cloudwatch graphs are fixed to a 5min period
See original GitHub issueWhen 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))
(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:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Looks like this issue has been fixed: https://github.com/aws/aws-cdk/pull/13078
@rix0rrr: Am I misunderstanding your comment, or was this issue closed in error?