-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathobservability-stack.ts
68 lines (57 loc) · 1.67 KB
/
observability-stack.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
import { Stack, StackProps } from 'aws-cdk-lib'
import { Construct } from 'constructs';
import { Color, Dashboard, GraphWidget, Metric } from 'aws-cdk-lib/aws-cloudwatch';
export class ObservabilityStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const disconnectionsMetric = new Metric({
namespace: 'websocket-chat',
metricName: 'closedConnection',
statistic: 'sum'
});
const newcConnectionsMetric = new Metric({
namespace: 'websocket-chat',
metricName: 'newConnection',
statistic: 'sum'
});
const messagesDeliveredMetric = new Metric({
namespace: 'websocket-chat',
metricName: 'messageDelivered',
statistic: 'sum'
});
var closedConnectionsWidget = new GraphWidget({
title: "Closed Connections",
width: 12,
left: [disconnectionsMetric.with({
color: Color.RED
})]
});
var newConnectionsWidget = new GraphWidget({
title: "New Connections",
width: 12,
left: [newcConnectionsMetric.with({
color: Color.GREEN
})]
});
var messagesDeliveredWidgets = new GraphWidget({
title: "Messages Delivered",
width: 24,
left: [messagesDeliveredMetric.with({
color: Color.GREEN
})]
});
const dashboard = new Dashboard(this, "Serverless Websocket Chat Dashboard", {
widgets: [
[
newConnectionsWidget,
closedConnectionsWidget
],
[
messagesDeliveredWidgets,
]
]
});
}
};