-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx_exports.ts
More file actions
236 lines (229 loc) · 6.28 KB
/
nginx_exports.ts
File metadata and controls
236 lines (229 loc) · 6.28 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
/**
* @description cloudwatch widgets for nginx workload
* @author @aws-solutions
*/
import { IExplorerWidget, ILogWidget, IMetricWidget } from "../generics";
//=============================================================================================
// Log widgets - cloudwatch log insights queries
//=============================================================================================
export const NginxLogWidgets: ILogWidget[] = [
/**
* @description remote IP widget for dashboard
*/
{
type: "log",
x: 0,
y: 0,
width: 12,
height: 6,
properties: {
view: "pie",
title: "Nginx Traffic by RemoteIP",
region: process.env.AWS_REGION as string,
query: `SOURCE "${process.env.ACCESS_LOG_GROUP}" | %%filter%%\n| stats count(remoteIP) as Count by remoteIP\n| sort Count desc\n| limit 10`,
},
},
/**
* @description host widget for dashboard
*/
{
type: "log",
x: 12,
y: 0,
width: 12,
height: 6,
properties: {
view: "pie",
title: "Nginx Traffic by Host",
region: process.env.AWS_REGION as string,
query: `SOURCE "${process.env.ACCESS_LOG_GROUP}" | %%filter%%\n| stats count(host) as Count by host\n| sort Count desc\n| limit 10`,
},
},
/**
* @description bytes sent widget for dashboard
*/
{
type: "log",
x: 0,
y: 6,
width: 12,
height: 6,
properties: {
view: "table",
title: "Nginx Traffic by BytesSent",
region: process.env.AWS_REGION as string,
query: `SOURCE "${process.env.ACCESS_LOG_GROUP}" | %%filter%%\n| stats SUM(bytesSent) as TotalBytesSent by filename\n| sort TotalBytesSent desc\n| limit 10`,
},
},
/**
* @description bytes received widget for dashboard
*/
{
type: "log",
x: 12,
y: 6,
width: 12,
height: 6,
properties: {
view: "table",
title: "Nginx Traffic by BytesReceived",
region: process.env.AWS_REGION as string,
query: `SOURCE "${process.env.ACCESS_LOG_GROUP}" | %%filter%%\n| stats SUM(bytesReceived) as TotalBytesReceived by filename\n| sort TotalBytesReceived desc\n| limit 10`,
},
},
/**
* @description response status widget for dashboard
*/
{
type: "log",
x: 0,
y: 12,
width: 12,
height: 6,
properties: {
view: "table",
title: "Nginx Traffic by Status",
region: process.env.AWS_REGION as string,
query: `SOURCE "${process.env.ACCESS_LOG_GROUP}" | %%filter%%\n| stats Count(status) as Count by status,filename\n| sort Count desc\n| limit 10`,
},
},
/**
* @description response time widget for dashboard
*/
{
type: "log",
x: 12,
y: 12,
width: 12,
height: 6,
properties: {
view: "table",
title: "Nginx Traffic by ResponseTime(µs)",
region: process.env.AWS_REGION as string,
query: `SOURCE "${process.env.ACCESS_LOG_GROUP}" | %%filter%%\n| sort responseTime desc\n| display remoteIP, request, responseTime\n| limit 10`,
},
},
/**
* @description response time widget for dashboard
*/
{
type: "log",
x: 12,
y: 12,
width: 12,
height: 6,
properties: {
view: "Line",
title: "Total Requests",
region: process.env.AWS_REGION as string,
query: `SOURCE "${process.env.ACCESS_LOG_GROUP}" | fields @timestamp, @message\n| sort @timestamp desc\n| stats count(@message) as connection_requests by bin(5ms)\n| limit 15`,
},
},
/**
* @description response time widget for dashboard
*/
{
type: "log",
x: 12,
y: 12,
width: 12,
height: 6,
properties: {
view: "Line",
title: "Total Active Connections",
region: process.env.AWS_REGION as string,
query: `SOURCE "${process.env.ACCESS_LOG_GROUP}" | fields @timestamp, @message\n| sort @timestamp desc\n| stats count(@message) as connection_active by bin(5ms)\n| limit 15`,
},
},
];
//=============================================================================================
// Metric Explorer widget - metrics with single dimension
//=============================================================================================
/**
* @description metric explorer widget for single dimension metrics on EC2
*/
export const NginxExplorerWidget: IExplorerWidget = {
type: "explorer",
x: 0,
y: 30,
width: 24,
height: 9,
properties: {
metrics: [
{
metricName: "netstat_tcp_established",
resourceType: "AWS::EC2::Instance",
stat: "Sum",
},
{
metricName: "mem_used_percent",
resourceType: "AWS::EC2::Instance",
stat: "Average",
},
],
labels: [
{
key: "",
value: "",
},
],
widgetOptions: {
legend: {
position: "bottom",
},
view: "timeSeries",
stacked: false,
rowsPerPage: 1,
widgetsPerRow: 2,
},
period: 300,
splitBy: "",
title: "Nginx Explorer",
},
};
//=============================================================================================
// Metric widget - metrics with multiple dimension
//=============================================================================================
/**
* @description apache CPU widget
*/
export const NginxMetricWidgets: IMetricWidget[] = [
{
type: "metric",
x: 0,
y: 27,
width: 24,
height: 6,
properties: {
metrics: [
[
"CWAgent",
"procstat_cpu_usage",
"exe",
"nginx",
"InstanceId",
"%%instance%%",
"process_name",
"nginx",
],
],
view: "timeSeries",
title: "Host Nginx CPU",
region: process.env.AWS_REGION as string,
period: 300,
stat: "Average",
},
},
];