Skip to content

Commit ae9c19b

Browse files
fix(UsageAlarmFactory): allowing addition of multiple alarms from the same class (#279)
Fixes # Addition of multiple alarms from the sameclass UsageAlarmFactory is creating same AlarmSuffix for every alarm that is being added in a class which leads to creation of duplicate alarms, as they have same name. This fix appends the UsageType to the alarm name thus allowing users to create alarm on avg, p50,p90... all metrics from the same class. --- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_
1 parent 8f413ed commit ae9c19b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

API.md

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/common/monitoring/alarms/UsageAlarmFactory.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ export class UsageAlarmFactory {
5959
addMaxCpuUsagePercentAlarm(
6060
percentMetric: MetricWithAlarmSupport,
6161
props: UsageThreshold,
62-
disambiguator?: string
62+
disambiguator?: string,
63+
usageType?: UsageType
6364
) {
65+
const alarmNameSuffix: string =
66+
usageType === undefined ? "CPU-Usage" : `${usageType}-CPU-Usage`;
6467
return this.alarmFactory.addAlarm(percentMetric, {
6568
treatMissingData:
6669
props.treatMissingDataOverride ?? TreatMissingData.MISSING,
@@ -70,7 +73,7 @@ export class UsageAlarmFactory {
7073
...props,
7174
disambiguator,
7275
threshold: props.maxUsagePercent,
73-
alarmNameSuffix: "CPU-Usage",
76+
alarmNameSuffix,
7477
alarmDescription: "The CPU usage is too high.",
7578
});
7679
}

0 commit comments

Comments
 (0)