Skip to content

(aws-cloudwatch): support Custom Widgets #17579

@Chriscbr

Description

@Chriscbr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-cloudwatchRelated to Amazon CloudWatcheffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions