Skip to content
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

(aws-cloudwatch): support Custom Widgets #17579

Closed
1 of 2 tasks
Chriscbr opened this issue Nov 19, 2021 · 1 comment · Fixed by #19327
Closed
1 of 2 tasks

(aws-cloudwatch): support Custom Widgets #17579

Chriscbr opened this issue Nov 19, 2021 · 1 comment · Fixed by #19327
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@Chriscbr
Copy link
Contributor

Chriscbr commented Nov 19, 2021

Description

Support CustomWidget as a type of CloudWatch widget that can be inserted in Dashboard's.

Most of the logic for customizing a CustomWidget has to be in the lambda code, but I think this L2 would still provide some value by automatically generating the dashboard JSON for you - we currently do that by hand in our implementation of a custom widget as seen here: https://github.com/cdklabs/construct-hub/blob/4e63b8a78c505aafdd035c7ed5cc0c382921d64d/src/backend/inventory/package-versions-table-widget.ts#L44

Use Case

I think there could be some potential to build construct libraries that provide different useful custom widgets. Custom widgets seem decently flexible since they can contain HTML, SVG's, and buttons that invoke other lambda's.

Proposed Solution

The CustomWidget would be a type of CloudWatch widget that extends ConcreteWidget. It could be configured with a required Lambda parameter (which when invoked should return the the content to display in the dashboard), as well as parameters for when the widget should automatically update.

Other information

Docs reference: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/add_custom_widget_dashboard.html

Full custom widget definition (provided since the full definition syntax / options still need to be added to the AWS docs):

{
    "height": 6,
    "width": 12,
    "y": 38,
    "x": 0,
    "type": "custom",
    "properties": {
        "title": "Sample: title",
        "endpoint": "arn:aws:lambda:us-east-1:012345678901:function:customWidgetLambdaFunctionName",
        "updateOn": {
            "refresh": true,
            "resize": false,
            "timeRange": false
        },
        "params": {
            "anything": "you-want",
            "this is": [ "custom", "params" ],
            "user-defined": true
        }
    }
}

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change
@Chriscbr Chriscbr added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 19, 2021
@github-actions github-actions bot added the @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch label Nov 19, 2021
@madeline-k madeline-k added effort/medium Medium work item – several days of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Nov 24, 2021
@madeline-k madeline-k removed their assignment Nov 24, 2021
@mergify mergify bot closed this as completed in #19327 May 2, 2022
mergify bot pushed a commit that referenced this issue May 2, 2022
This PR introcudes the CustomWidget for Cloudwatch Dashboards

fixes: #17579

based on the work of @dannyber

If you wonder, why only a string typed option was used instead of an lambda.IFunction, the reason is, that this would introduce a circular dependency between lambda -> cloudwatch -> lambda and leads to build errors.

Creating a new package for this tiny feature to work around the circular dependency would be too much of a good thing. Apart from that it could be unintuitive to find the custom widget in a package 'aws-cloudwatch-pattarns' if all other widgets come from 'aws-cloudwatch'.

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented May 2, 2022

⚠️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.

wphilipw pushed a commit to wphilipw/aws-cdk that referenced this issue May 23, 2022
This PR introcudes the CustomWidget for Cloudwatch Dashboards

fixes: aws#17579

based on the work of @dannyber

If you wonder, why only a string typed option was used instead of an lambda.IFunction, the reason is, that this would introduce a circular dependency between lambda -> cloudwatch -> lambda and leads to build errors.

Creating a new package for this tiny feature to work around the circular dependency would be too much of a good thing. Apart from that it could be unintuitive to find the custom widget in a package 'aws-cloudwatch-pattarns' if all other widgets come from 'aws-cloudwatch'.

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants