-
Notifications
You must be signed in to change notification settings - Fork 4k
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
cloudwatch: make metricName field public #33570
Comments
@rantoniuk Good morning. Thanks for opening the issue. Although it's debatable, shouldn't the above code written like this: const sigkillMetric = new Metric({
namespace: metricNamespace,
metricName: SigkillCount,
statistic: 'Sum',
period: Duration.minutes(5),
});
const sigkillMetricFilter = new MetricFilter(this, 'SigkillMetricFilter', {
filterPattern: FilterPattern.literal('SIGKILL'),
logGroup: this.logGroup,
metricNamespace,
metricName: sigkillMetric.metricName,
metricValue: '1',
}); In other words, we should define metric first and then use it's object to reference Thanks, |
Yes, that's perfectly fine, thanks for pointing that out! However, I think I'm missing something here. See the below code: const sigkillMetric = new Metric({
namespace: 'reportgen',
metricName: 'SigkillCount',
statistic: 'Sum',
period: Duration.minutes(5),
});
const sigkillMetricFilter = new MetricFilter(this, 'SigkillMetricFilter', {
filterPattern: FilterPattern.literal('SIGKILL'),
logGroup: this.logGroup,
metricNamespace: sigkillMetric.namespace,
metricName: sigkillMetric.metricName,
metricValue: '1',
});
const sigkillAlarm = new Alarm(this, 'SigkillAlarm', {
alarmName: 'SIGKILL-Alarm',
metric: sigkillMetric,
threshold: 1,
evaluationPeriods: 1,
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
treatMissingData: TreatMissingData.NOT_BREACHING,
}); Now, the above code does what I want it to do, i.e. sets up alarm for SUM, 5min. However, you can notice that the alarm refers directly to the metric and not the metric filter. This is fine, I'm just curious why the below doesn't do the same: const sigkillAlarm = new Alarm(this, 'SigkillAlarm', {
alarmName: 'SIGKILL-Alarm',
metric: sigkillMetricFilter.metric(), // CHANGE
threshold: 1,
evaluationPeriods: 1,
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
treatMissingData: TreatMissingData.NOT_BREACHING,
}); When I do this,
Is that expected? it should return a ref to the metric object that has |
@rantoniuk Good morning. Could you please share self-contained code to troubleshoot the issue? Also share the output of Thanks, |
You can find the code already above. As requested, I did a template diff between const sigkillAlarm = new Alarm(this, 'SigkillAlarm', {
alarmName: 'SIGKILL-Alarm',
metric: sigkillMetric,
threshold: 1,
evaluationPeriods: 1,
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
treatMissingData: TreatMissingData.NOT_BREACHING,
}); and const sigkillAlarm = new Alarm(this, 'SigkillAlarm', {
alarmName: 'ReportGen-SIGKILL-Alarm',
metric: sigkillMetricFilter.metric(),
threshold: 1,
evaluationPeriods: 1,
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
treatMissingData: TreatMissingData.NOT_BREACHING,
}); Result:
I think the problem (CDK-wise) is that the
|
Describe the feature
In the following code:
the metricName field is duplicated in two constructs, because it's not possible to do:
This doesn't allow for proper object dependency/relationship.
Use Case
As above.
Proposed Solution
Make the field public.
Other Information
No response
Acknowledgements
CDK version used
[email protected]
Environment details (OS name and version, etc.)
MacOS
The text was updated successfully, but these errors were encountered: