(aws-cloudwatch): Missing ids when creating math expressions
See original GitHub issueThere’s no way to assign an ID to a metric in CDK at this point. If you’re creating multiple math expressions within a single dashboard widget, the IDs for the math expressions are missing, and you’ll see that they have the same IDs in the CloudWatch Dashboard, and the metrics in the dashboard widget will be messed up.
Reproduction Steps
new cloudWatch.GraphWidget({
left: [
new MathExpression(...),
new MathExpression(...),
new MathExpression(...)
]
});
The generated CloudFormation file doesn’t contain ID for MathExpression (see example below). After deployed, in the CloudWatch, we’ll see that all the math expressions are assigned with the same ID, and the dashboard widget shows incorrect metrics
{ "label": "percentage", "expression": "m1 / m2", "region": "us-east-1" }
What did you expect to happen?
- There should be a way to auto or manually set the ID for MathExpression
- The above example should finally contain an id, something like
{ "label": "percentage", "expression": "m1 / m2", "region": "us-east-1", id: "e1" }
What actually happened?
The generated Math Expression widget doesn’t have an id
{ "label": "percentage", "expression": "m1 / m2", "region": "us-east-1" }
Environment
- CDK CLI Version : any
- Framework Version: 1.95
- Node.js Version: any
- OS : any
- Language (Version): TypeScript (but I think this issue is in all the languages)
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 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 >Creating a CloudWatch alarm based on a metric math ...
You can't create an alarm based on the SEARCH expression. This is because search expressions return multiple time series, and an alarm based...
Read more >Create a metric math alarm using Amazon CloudWatch
In this blog post, you'll create an alarm for a metric math expression that calculates the AWS Lambda error rate. You want to...
Read more >Using Amazon CloudWatch metrics math to monitor and scale ...
Metric math enables you to query multiple CloudWatch metrics and use math expressions to create new time series based on these metrics.
Read more >Amazon CloudWatch concepts - AWS Documentation
You can't retrieve statistics for the following dimensions or if you specify no dimensions. (The exception is by using the metric math SEARCH...
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
If any1 else is still facing this issue: I managed to hack around it in python, something similar could work in other languages as well:
helper class:
Usage: Replace:
aws_cloudwatch.Metric(namespace="AWS/EC2", metric_name="NetworkIn")
with:MyMetric(namespace="AWS/EC2", metric_name="NetworkIn").addProperties({"id": "yourid", "visible": false})
⚠️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.