aws / aws/aws-cdk

(aws-cloudwatch): Sort visible metrics first in widgets

Open
#36,079 1 comment 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-cloudwatch effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

Change the behavior of how metrics are sorted in CloudWatch Dashboard Widgets so that visible metrics appear first.

### Use Case

Using multiple `MathExpression`s in the same widget leads to difficult to decipher graphs, because the colors of visible metrics are very similar. See the screenshot for an example: in view, there are 3 visible metrics, but because there are many hidden metrics between the visible ones, the automatic colors chosen aren't easily distinguishable.

Image

### Proposed Solution

Before rendering the dashboard json of a widget, sort the metrics by visible first. This would make CloudWatch's automatic color scheme work much better for the metrics that actually appear in the widget.

### Other Information

*Note: I do know that defining the colors manually is possible, but this is not a good solution for a few reasons. Namely, I don't always know how many metrics will be in a widget and I would prefer not to re-implement the automatic color generation how CloudWatch does it*

I've created a sample dashboard in [this repository](https://github.com/jackrein/aws-cdk-cloudwatch-math-expression-widget) to demonstrate this behavior.

### Acknowledgements

- [x] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### AWS CDK Library version (aws-cdk-lib)

aws-cdk-lib@2.215.0

### AWS CDK CLI version

2.1031.2 (build 779352d)

### Environment details (OS name and version, etc.)

Amazon Linux 2

Contributor guide

Open the contributing guide

Research direction

No implementation file or test is named. Start by locating the TypeScript CloudWatch dashboard widget code that renders dashboard JSON, then trace how metric visibility is represented and ordered; done means visible metrics precede hidden metrics without changing the widget's other output.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, observability
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.