aws / aws/aws-cdk

cloudwatch: make metricName field public

Open
#33,570 4 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-cloudwatch feature-request p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

In the following code:
```ts
const sigkillMetricFilter = new MetricFilter(this, 'SigkillMetricFilter', {
filterPattern: FilterPattern.literal('SIGKILL'),
logGroup: this.logGroup,
metricNamespace,
metricName: 'SigkillCount',
metricValue: '1',
});

// Create a metric using the filter
const sigkillMetric = new Metric({
namespace: metricNamespace,
metricName: 'SigkillCount',
statistic: 'Sum',
period: Duration.minutes(5),
});
```

the metricName field is duplicated in two constructs, because it's not possible to do:
```ts
const sigkillMetric = new Metric({
namespace: metricNamespace,
metricName: sigkillMetricFilter.metricName, // this field is private
statistic: 'Sum',
period: Duration.minutes(5),
});
```

This doesn't allow for proper object dependency/relationship.

### Use Case

As above.

### Proposed Solution

Make the field public.

### Other Information

_No response_

### Acknowledgements

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

### CDK version used

aws-cdk-lib@2.180.0

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

MacOS

Contributor guide

Open the contributing guide

Research direction

Start at the TypeScript MetricFilter construct shown in the issue and inspect how metricName is declared and covered by existing tests. Make the property accessible to consumers without changing its value, then run the relevant CloudWatch or MetricFilter tests and confirm the example can use sigkillMetricFilter.metricName.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, observability
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.