-
Notifications
You must be signed in to change notification settings - Fork 27
/
ObservabilityStack.cs
88 lines (80 loc) · 2.92 KB
/
ObservabilityStack.cs
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System.Collections.Generic;
using Amazon.CDK;
using Amazon.CDK.AWS.CloudWatch;
using Constructs;
namespace Infrastructure.Stacks
{
public class ObservabilityStack : Stack
{
internal ObservabilityStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
#region Metrics
var disconnectionsMetric = new Metric(new MetricProps()
{
Namespace = "websocket-chat",
DimensionsMap = new Dictionary<string, string>() {{"Service", "service_undefined"}},
MetricName = "closedConnection",
Statistic = "sum"
});
var newConnectionsMetric = new Metric(new MetricProps()
{
Namespace = "websocket-chat",
DimensionsMap = new Dictionary<string, string>() {{"Service", "service_undefined"}},
MetricName = "newConnection",
Statistic = "sum"
});
var messagesDeliveredMetric = new Metric(new MetricProps()
{
Namespace = "websocket-chat",
DimensionsMap = new Dictionary<string, string>() {{"Service", "service_undefined"}},
MetricName = "messageDelivered",
Statistic = "sum"
});
#endregion
#region Widgets
var closedConnectionsWidget = new GraphWidget(new GraphWidgetProps()
{
Title = "Closed Connections",
Width = 12,
Left = new[]{ disconnectionsMetric.With(new MetricOptions()
{
Color = Color.RED
})}
});
var newConnectionsWidget = new GraphWidget(new GraphWidgetProps()
{
Title = "New Connections",
Width = 12,
Left = new[]{ newConnectionsMetric.With(new MetricOptions()
{
Color = Color.GREEN
})}
});
var messagesDeliveredWidgets = new GraphWidget(new GraphWidgetProps()
{
Title = "Messages Delivered",
Width = 24,
Left = new[]{ messagesDeliveredMetric.With(new MetricOptions()
{
Color = Color.GREEN
})}
});
#endregion
var dashboard = new Dashboard(this, "Serverless Websocket Chat Dashboard", new DashboardProps()
{
Widgets = new []
{
new []
{
newConnectionsWidget,
closedConnectionsWidget
},
new []
{
messagesDeliveredWidgets
}
}
});
}
}
}