Skip to content

Commit b9176a5

Browse files
author
Eugene Cheung
authored
feat(logs): add addMaxIncomingLogsAlarm (#504)
Closes #495 --- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_
1 parent 040845d commit b9176a5

File tree

4 files changed

+77
-3
lines changed

4 files changed

+77
-3
lines changed

API.md

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/monitoring/aws-cloudwatch/LogMonitoring.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
DefaultLogWidgetHeight,
1818
DefaultSummaryWidgetHeight,
1919
FullWidth,
20+
MaxUsageCountThreshold,
2021
MetricWithAlarmSupport,
2122
MinUsageCountThreshold,
2223
Monitoring,
@@ -55,6 +56,7 @@ export interface LogMonitoringProps
5556
readonly limit?: number;
5657

5758
readonly addMinIncomingLogsAlarm?: Record<string, MinUsageCountThreshold>;
59+
readonly addMaxIncomingLogsAlarm?: Record<string, MaxUsageCountThreshold>;
5860
}
5961

6062
/**
@@ -116,6 +118,17 @@ export class LogMonitoring extends Monitoring {
116118
this.addAlarm(createdAlarm);
117119
}
118120

121+
for (const disambiguator in props.addMaxIncomingLogsAlarm) {
122+
const alarmProps = props.addMaxIncomingLogsAlarm[disambiguator];
123+
const createdAlarm = this.usageAlarmFactory.addMaxCountAlarm(
124+
this.incomingLogEventsMetric,
125+
alarmProps,
126+
disambiguator
127+
);
128+
this.usageAnnotations.push(createdAlarm.annotation);
129+
this.addAlarm(createdAlarm);
130+
}
131+
119132
props.useCreatedAlarms?.consume(this.createdAlarms());
120133
}
121134

test/monitoring/aws-cloudwatch/LogMonitoring.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ test("snapshot test: with alarms", () => {
6565
treatMissingDataOverride: TreatMissingData.BREACHING,
6666
},
6767
},
68+
addMaxIncomingLogsAlarm: {
69+
Critical: {
70+
maxCount: 9001,
71+
},
72+
},
6873
useCreatedAlarms: {
6974
consume(alarms) {
7075
numAlarmsCreated = alarms.length;
@@ -73,6 +78,6 @@ test("snapshot test: with alarms", () => {
7378
});
7479

7580
addMonitoringDashboardsToStack(stack, monitoring);
76-
expect(numAlarmsCreated).toStrictEqual(1);
81+
expect(numAlarmsCreated).toStrictEqual(2);
7782
expect(Template.fromStack(stack)).toMatchSnapshot();
7883
});

test/monitoring/aws-cloudwatch/__snapshots__/LogMonitoring.test.ts.snap

Lines changed: 47 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)