Skip to content

Commit 0fd2015

Browse files
author
Eugene Cheung
authored
fix(loadbalancing): fix duplicate summary graphs for NLBs (#175)
Reported by a customer. Also adding dashboard snapshots to the `aws-loadbalancing` tests. --- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_
1 parent a8d736b commit 0fd2015

File tree

5 files changed

+2193
-22
lines changed

5 files changed

+2193
-22
lines changed

lib/monitoring/aws-loadbalancing/NetworkLoadBalancerMonitoring.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class NetworkLoadBalancerMonitoring extends Monitoring {
148148
summaryWidgets(): IWidget[] {
149149
return [
150150
this.createTitleWidget(),
151-
this.createTaskHealthWidget(HalfWidth, DefaultSummaryWidgetHeight),
151+
this.createTcpFlowsWidget(HalfWidth, DefaultSummaryWidgetHeight),
152152
this.createTaskHealthWidget(HalfWidth, DefaultSummaryWidgetHeight),
153153
];
154154
}

test/monitoring/aws-loadbalancing/ApplicationLoadBalancerMonitoring.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
Ec2ServiceMonitoring,
1818
FargateServiceMonitoring,
1919
} from "../../../lib";
20+
import { addMonitoringDashboardsToStack } from "../../utils/SnapshotUtil";
2021
import { TestMonitoringScope } from "../TestMonitoringScope";
2122

2223
// FARGATE SERVICE
@@ -46,13 +47,14 @@ test("snapshot alb test: no alarms", () => {
4647
.addListener("Listener", { port: 80 })
4748
.addTargets("Target", { port: 80, targets: [fargateService] });
4849

49-
new FargateServiceMonitoring(scope, {
50+
const monitoring = new FargateServiceMonitoring(scope, {
5051
fargateService,
5152
loadBalancer: applicationLoadBalancer,
5253
targetGroup: applicationTargetGroup,
5354
alarmFriendlyName: "DummyFargateService",
5455
});
5556

57+
addMonitoringDashboardsToStack(stack, monitoring);
5658
expect(Template.fromStack(stack)).toMatchSnapshot();
5759
});
5860

@@ -82,7 +84,7 @@ test("snapshot alb test: all alarms", () => {
8284

8385
let numAlarmsCreated = 0;
8486

85-
new FargateServiceMonitoring(scope, {
87+
const monitoring = new FargateServiceMonitoring(scope, {
8688
fargateService,
8789
loadBalancer: applicationLoadBalancer,
8890
targetGroup: applicationTargetGroup,
@@ -129,6 +131,7 @@ test("snapshot alb test: all alarms", () => {
129131
},
130132
});
131133

134+
addMonitoringDashboardsToStack(stack, monitoring);
132135
expect(numAlarmsCreated).toStrictEqual(7);
133136
expect(Template.fromStack(stack)).toMatchSnapshot();
134137
});
@@ -164,13 +167,14 @@ test("snapshot ec2 alb test: no alarms", () => {
164167
.addListener("Listener", { port: 80 })
165168
.addTargets("Target", { port: 80, targets: [ec2Service] });
166169

167-
new Ec2ServiceMonitoring(scope, {
170+
const monitoring = new Ec2ServiceMonitoring(scope, {
168171
ec2Service,
169172
loadBalancer: applicationLoadBalancer,
170173
targetGroup: applicationTargetGroup,
171174
alarmFriendlyName: "DummyEc2Service",
172175
});
173176

177+
addMonitoringDashboardsToStack(stack, monitoring);
174178
expect(Template.fromStack(stack)).toMatchSnapshot();
175179
});
176180

@@ -203,7 +207,7 @@ test("snapshot ec2 alb test: all alarms", () => {
203207

204208
let numAlarmsCreated = 0;
205209

206-
new Ec2ServiceMonitoring(scope, {
210+
const monitoring = new Ec2ServiceMonitoring(scope, {
207211
ec2Service,
208212
loadBalancer: applicationLoadBalancer,
209213
targetGroup: applicationTargetGroup,
@@ -250,6 +254,7 @@ test("snapshot ec2 alb test: all alarms", () => {
250254
},
251255
});
252256

257+
addMonitoringDashboardsToStack(stack, monitoring);
253258
expect(numAlarmsCreated).toStrictEqual(7);
254259
expect(Template.fromStack(stack)).toMatchSnapshot();
255260
});

test/monitoring/aws-loadbalancing/NetworkLoadBalancerMonitoring.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
AlarmWithAnnotation,
88
NetworkLoadBalancerMonitoring,
99
} from "../../../lib";
10+
import { addMonitoringDashboardsToStack } from "../../utils/SnapshotUtil";
1011
import { TestMonitoringScope } from "../TestMonitoringScope";
1112

1213
test("snapshot nlb test: no alarms", () => {
@@ -22,12 +23,13 @@ test("snapshot nlb test: no alarms", () => {
2223
.addListener("Listener", { port: 80 })
2324
.addTargets("Target", { port: 80 });
2425

25-
new NetworkLoadBalancerMonitoring(scope, {
26+
const monitoring = new NetworkLoadBalancerMonitoring(scope, {
2627
networkLoadBalancer,
2728
networkTargetGroup,
2829
alarmFriendlyName: "DummyNetworkLoadBalancer",
2930
});
3031

32+
addMonitoringDashboardsToStack(stack, monitoring);
3133
expect(Template.fromStack(stack)).toMatchSnapshot();
3234
});
3335

@@ -46,7 +48,7 @@ test("snapshot nlb test: all alarms", () => {
4648

4749
let numAlarmsCreated = 0;
4850

49-
new NetworkLoadBalancerMonitoring(scope, {
51+
const monitoring = new NetworkLoadBalancerMonitoring(scope, {
5052
networkLoadBalancer,
5153
networkTargetGroup,
5254
alarmFriendlyName: "DummyNetworkLoadBalancer",
@@ -77,6 +79,7 @@ test("snapshot nlb test: all alarms", () => {
7779
},
7880
});
7981

82+
addMonitoringDashboardsToStack(stack, monitoring);
8083
expect(numAlarmsCreated).toStrictEqual(4);
8184
expect(Template.fromStack(stack)).toMatchSnapshot();
8285
});

0 commit comments

Comments
 (0)