-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(cloudwatch): add id and visible properties for CloudWatch Metric #34870
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
Changes from 8 commits
019258f
e7bd555
8a9ca69
b823776
88058bd
eae8ebe
34c4194
aa3d26e
6d65f86
b0b5849
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| { | ||
| "Resources": { | ||
| "DashCCD7F836": { | ||
| "Type": "AWS::CloudWatch::Dashboard", | ||
| "Properties": { | ||
| "DashboardBody": { | ||
| "Fn::Join": [ | ||
| "", | ||
| [ | ||
| "{\"widgets\":[{\"type\":\"metric\",\"width\":6,\"height\":6,\"x\":0,\"y\":0,\"properties\":{\"view\":\"timeSeries\",\"title\":\"Metrics with id and visible properties\",\"region\":\"", | ||
| { | ||
| "Ref": "AWS::Region" | ||
| }, | ||
| "\",\"metrics\":[[\"CDK/Test\",\"Metric1\",{\"label\":\"Visible metric with custom ID\",\"id\":\"custom_metric_id\",\"visible\":true}],[\"CDK/Test\",\"Metric2\",{\"label\":\"Hidden metric for calculations\",\"id\":\"hidden_metric_id\",\"visible\":false}],[\"CDK/Test\",\"Metric3\",{\"label\":\"Metric with only ID\",\"id\":\"id_only_metric\"}],[\"CDK/Test\",\"Metric4\",{\"label\":\"Metric with only visible\",\"visible\":true}],[\"CDK/Test\",\"Metric5\",{\"label\":\"Right side hidden metric\",\"id\":\"right_hidden_id\",\"visible\":false,\"yAxis\":\"right\"}]],\"yAxis\":{}}}]}" | ||
| ] | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "Parameters": { | ||
| "BootstrapVersion": { | ||
| "Type": "AWS::SSM::Parameter::Value<String>", | ||
| "Default": "/cdk-bootstrap/hnb659fds/version", | ||
| "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
| } | ||
| }, | ||
| "Rules": { | ||
| "CheckBootstrapVersion": { | ||
| "Assertions": [ | ||
| { | ||
| "Assert": { | ||
| "Fn::Not": [ | ||
| { | ||
| "Fn::Contains": [ | ||
| [ | ||
| "1", | ||
| "2", | ||
| "3", | ||
| "4", | ||
| "5" | ||
| ], | ||
| { | ||
| "Ref": "BootstrapVersion" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }, | ||
| "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { App, Stack, StackProps } from 'aws-cdk-lib'; | ||
| import { IntegTest } from '@aws-cdk/integ-tests-alpha'; | ||
| import { Dashboard, Metric, GraphWidget } from 'aws-cdk-lib/aws-cloudwatch'; | ||
|
|
||
| class DashboardWithMetricIdAndVisibleIntegrationTest extends Stack { | ||
| constructor(scope: App, id: string, props?: StackProps) { | ||
| super(scope, id, props); | ||
|
|
||
| const dashboard = new Dashboard(this, 'Dash'); | ||
|
|
||
| const widget = new GraphWidget({ | ||
| title: 'Metrics with id and visible properties', | ||
| left: [ | ||
| new Metric({ | ||
| namespace: 'CDK/Test', | ||
| metricName: 'Metric1', | ||
| label: 'Visible metric with custom ID', | ||
| id: 'custom_metric_id', | ||
| visible: true, | ||
| }), | ||
|
|
||
| new Metric({ | ||
| namespace: 'CDK/Test', | ||
| metricName: 'Metric2', | ||
| label: 'Hidden metric for calculations', | ||
| id: 'hidden_metric_id', | ||
| visible: false, | ||
| }), | ||
|
|
||
| new Metric({ | ||
| namespace: 'CDK/Test', | ||
| metricName: 'Metric3', | ||
| label: 'Metric with only ID', | ||
| id: 'id_only_metric', | ||
| }), | ||
|
|
||
| new Metric({ | ||
| namespace: 'CDK/Test', | ||
| metricName: 'Metric4', | ||
| label: 'Metric with only visible', | ||
| visible: true, | ||
| }), | ||
| ], | ||
| right: [ | ||
| new Metric({ | ||
| namespace: 'CDK/Test', | ||
| metricName: 'Metric5', | ||
| label: 'Right side hidden metric', | ||
| id: 'right_hidden_id', | ||
| visible: false, | ||
| }), | ||
| ], | ||
| }); | ||
|
|
||
| dashboard.addWidgets(widget); | ||
| } | ||
| } | ||
|
|
||
| const app = new App(); | ||
| new IntegTest(app, 'cdk-integ-dashboard-with-metric-id-and-visible', { | ||
| testCases: [new DashboardWithMetricIdAndVisibleIntegrationTest(app, 'DashboardWithMetricIdAndVisibleIntegrationTest')], | ||
| }); | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The integration test is good, but it doesn't demonstrate the primary use case of using the id property with math expressions as described in the issue. Improve the integration test to include a math expression that references metrics by their IDs, which would better validate the actual use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made some changes to include usage of ID of predefined metrics inside math expression.