Support for CloudWatch InsightRule as a Higher Level Construct
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
In 2019, CloudWatch announced a new product called "Contributor Insights". It allows you to see high cardinality Top-N data of things like:
* Highest rate of throttle keys in DDB
* Highest callers in APIGateway
* Highest error rate of callers
or anything that you configure from your logs. It's truly amazing. I see that it exists as a [Cloudformation resource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-insightrule.html) and an [autogenerated resource](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cloudwatch.CfnInsightRule.html)
Insights break a lot of the previous paradigms though:
* you can use new statistics types to slice out data within an insight rule. As an example, Top-100 shows the top 100 accessed keys in DDB. For every datapoint, you have [2 new statistics of "UniqueContributors" and "MaxContributorValue"](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContributorInsights-GraphReportData.html), this means for DDB you could do a metric graph of "percent keys throttled" where you take `INSIGHT_RULE_METRIC(DDB-ThrottledKeys, UniqueContributors)/INSIGHT_RULE_METRIC(DDB-AccessedKeys, UniqueContributors)` which is pretty cool. Those statistics are only for Insights today though..
* It's properties are weird in a dashboard compared to that of a metrics object (e.g. no "metrics" property).
### Use Case
I use Contributor Insights and want to put it in dashboards at a higher level than the autogenerated resource :)
### Proposed Solution
I need to take a look a bit more and I kinda want to use this issue as the place for that discussion.
There are a lot of things that don't jive well if I were to make this a Metric...or even an IMetric. As an example, the current implementation of [statistic](https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-cloudwatch/lib/metric-types.ts#L46-L52) works well with the superset of both {Metric, Insight} but if I were to add the 2 new statistics mentioned above, you would have 2 statistics that only are valid on an Insight, which I assume most people *don't* use today. That would be...odd. Though technically it is a statistic.. ¯\\_(ツ)_/¯
This goes down the rabbit hole. Like metrics have namespaces, dimensions, all this stuff that insights do not have. It makes me wonder "is this really a metric". Answer is probably not, so we would need to create something else that would work well with Dashboards/Alarms that's "similar to a metric but not a metric".
### Other
* [x] :wave: I may be able to implement this feature request
* [ ] :warning: This feature might incur a breaking change
---
This is a :rocket: Feature Request
Contributor guide
Research direction
Start with the autogenerated CfnInsightRule resource and the statistic implementation in packages/@aws-cdk/aws-cloudwatch/lib/metric-types.ts. Read the CloudFormation InsightRule and dashboard references linked in the issue, then clarify how a higher-level construct should represent InsightRule statistics and dashboard properties. Done means an agreed construct design that supports Contributor Insights in dashboards without assuming it is a standard metric.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100