-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Closed
Copy link
Labels
@aws-cdk/aws-cloudwatchRelated to Amazon CloudWatchRelated to Amazon CloudWatcheffort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortfeature-requestA feature should be added or improved.A feature should be added or improved.p2
Description
Describe the feature
Currently some cloudwatch Metric properties can't be set using the cdk. Two of these are "id" and "visible".
Use Case
I would like to use SUM(METRICS("metrix_prefix")), while hiding the basic metrics, eg:
{
"view": "timeSeries",
"title": "Http Requests/Errors (SUM)",
"region": "us-east-1",
"metrics": [
[ { "label": "SumErrors", "expression": "SUM(METRICS(\"http_error\"))", "period": 10, "region": "us-east-1" } ],
[ { "label": "SumRequests", "expression": "SUM(METRICS(\"http_requests\"))", "period": 10, "region": "us-east-1" } ],
[ ".", "HttpErrors", ".", ".", { "label": "HttpErrors - us-east-1", "id": "http_errors_us_east_1", "visible": false, "period": 10 } ],
[ ".", "HttpRequest", ".", ".", { "label": "HttpRequests - eu-west-1", "id": "http_requests_eu_west_1", "visible": false, "period": 10 } ,
[ ".", "HttpErrors", ".", ".", { "label": "HttpErrors - us-east-1", "id": "http_errors_us_east_1", "visible": false, "period": 10 } ],
[ ".", "HttpRequest", ".", ".", { "label": "HttpRequests - eu-west-1", "id": "http_requests_eu_west_1", "visible": false, "period": 10 } ]
],
"period": 300
}
(I apologize if there is some syntax error above, this is a simplification of our actual use case.)
Proposed Solution
Allow setting "id" and "visible" properties from the cdk (there might be other properties as well, that i haven't run into).
Other Information
There is a similar issue that got closed recently: #13942 (comment), but i feel the use-case is different enough to warrant a separate issue.
I currently use the following workaround in the python sdk:
...
sumWidget.add_left_metric(MyMetric(label=f"{name} - {region}", metric_name=name, **_kwargs).addProperties({"id": f"{id}_{regionUnderscore}", "visible": False}))
...
class MyMetric(aws_cloudwatch.Metric):
def __init__(self, *args, **kwargs):
super(MyMetric, self).__init__(*args, **kwargs)
def addProperties(self, props):
self.props = props
return self
def to_metric_config(self) -> aws_cloudwatch.MetricConfig:
result = super(MyMetric, self).to_metric_config()
if not hasattr(self, "props"):
return result
if "rendering_properties" in result._values:
result._values["rendering_properties"].update(self.props)
else:
result._values["rendering_properties"] = self.props
return result
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
aws-cdk.aws-cloudwatch-1.132.0, but also checked the latest documentations (1.152.0 and 2.20.0):
- https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-cloudwatch.Metric.html
- https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.Metric.html
Environment details (OS name and version, etc.)
doesn't matter
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-cloudwatchRelated to Amazon CloudWatchRelated to Amazon CloudWatcheffort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortfeature-requestA feature should be added or improved.A feature should be added or improved.p2