Skip to content

Commit ccb148f

Browse files
Furistoroboquat
authored andcommitted
[observability] Add dashboard for network limiting
1 parent 65e872b commit ccb148f

File tree

2 files changed

+347
-4
lines changed

2 files changed

+347
-4
lines changed

components/ws-daemon/pkg/netlimit/netlimit.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package netlimit
77
import (
88
"context"
99
"fmt"
10+
"os"
1011
"os/exec"
1112

1213
"runtime"
@@ -36,12 +37,12 @@ func NewConnLimiter(config Config, prom prometheus.Registerer) *ConnLimiter {
3637
droppedBytes: prometheus.NewGaugeVec(prometheus.GaugeOpts{
3738
Name: "netlimit_connections_dropped_bytes",
3839
Help: "Number of bytes dropped due to connection limiting",
39-
}, []string{"workspace"}),
40+
}, []string{"node", "workspace"}),
4041

4142
droppedPackets: prometheus.NewGaugeVec(prometheus.GaugeOpts{
4243
Name: "netlimit_connections_dropped_packets",
4344
Help: "Number of packets dropped due to connection limiting",
44-
}, []string{"workspace"}),
45+
}, []string{"node", "workspace"}),
4546
limited: map[string]struct{}{},
4647
}
4748

@@ -155,8 +156,9 @@ func (c *ConnLimiter) limitWorkspace(ctx context.Context, ws *dispatch.Workspace
155156
continue
156157
}
157158

158-
c.droppedBytes.WithLabelValues(ws.InstanceID).Set(float64(counter.Bytes))
159-
c.droppedPackets.WithLabelValues(ws.InstanceID).Set(float64(counter.Packets))
159+
nodeName := os.Getenv("NODENAME")
160+
c.droppedBytes.WithLabelValues(nodeName, ws.Pod.Name).Set(float64(counter.Bytes))
161+
c.droppedPackets.WithLabelValues(nodeName, ws.Pod.Name).Set(float64(counter.Packets))
160162

161163
case <-ctx.Done():
162164
c.mu.Lock()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,341 @@
1+
{
2+
"__inputs": [
3+
{
4+
"name": "DS_PROMETHEUS",
5+
"label": "prometheus",
6+
"description": "",
7+
"type": "datasource",
8+
"pluginId": "prometheus",
9+
"pluginName": "Prometheus"
10+
}
11+
],
12+
"__elements": {},
13+
"__requires": [
14+
{
15+
"type": "grafana",
16+
"id": "grafana",
17+
"name": "Grafana",
18+
"version": "9.1.0"
19+
},
20+
{
21+
"type": "datasource",
22+
"id": "prometheus",
23+
"name": "Prometheus",
24+
"version": "1.0.0"
25+
},
26+
{
27+
"type": "panel",
28+
"id": "timeseries",
29+
"name": "Time series",
30+
"version": ""
31+
}
32+
],
33+
"annotations": {
34+
"list": [
35+
{
36+
"builtIn": 1,
37+
"datasource": {
38+
"type": "grafana",
39+
"uid": "-- Grafana --"
40+
},
41+
"enable": true,
42+
"hide": true,
43+
"iconColor": "rgba(0, 211, 255, 1)",
44+
"name": "Annotations & Alerts",
45+
"target": {
46+
"limit": 100,
47+
"matchAny": false,
48+
"tags": [],
49+
"type": "dashboard"
50+
},
51+
"type": "dashboard"
52+
}
53+
]
54+
},
55+
"description": "Shows statistics about network limiting",
56+
"editable": true,
57+
"fiscalYearStartMonth": 0,
58+
"graphTooltip": 0,
59+
"id": null,
60+
"links": [],
61+
"liveNow": false,
62+
"panels": [
63+
{
64+
"datasource": {
65+
"type": "prometheus",
66+
"uid": "${DS_PROMETHEUS}"
67+
},
68+
"fieldConfig": {
69+
"defaults": {
70+
"color": {
71+
"mode": "palette-classic"
72+
},
73+
"custom": {
74+
"axisCenteredZero": false,
75+
"axisColorMode": "text",
76+
"axisLabel": "",
77+
"axisPlacement": "auto",
78+
"barAlignment": 0,
79+
"drawStyle": "line",
80+
"fillOpacity": 0,
81+
"gradientMode": "none",
82+
"hideFrom": {
83+
"legend": false,
84+
"tooltip": false,
85+
"viz": false
86+
},
87+
"lineInterpolation": "linear",
88+
"lineWidth": 1,
89+
"pointSize": 5,
90+
"scaleDistribution": {
91+
"type": "linear"
92+
},
93+
"showPoints": "auto",
94+
"spanNulls": false,
95+
"stacking": {
96+
"group": "A",
97+
"mode": "none"
98+
},
99+
"thresholdsStyle": {
100+
"mode": "off"
101+
}
102+
},
103+
"mappings": [],
104+
"thresholds": {
105+
"mode": "absolute",
106+
"steps": [
107+
{
108+
"color": "green",
109+
"value": null
110+
},
111+
{
112+
"color": "red",
113+
"value": 80
114+
}
115+
]
116+
}
117+
},
118+
"overrides": []
119+
},
120+
"gridPos": {
121+
"h": 9,
122+
"w": 12,
123+
"x": 0,
124+
"y": 0
125+
},
126+
"id": 2,
127+
"options": {
128+
"legend": {
129+
"calcs": [],
130+
"displayMode": "list",
131+
"placement": "bottom",
132+
"showLegend": true
133+
},
134+
"tooltip": {
135+
"mode": "single",
136+
"sort": "none"
137+
}
138+
},
139+
"targets": [
140+
{
141+
"datasource": {
142+
"type": "prometheus",
143+
"uid": "${DS_PROMETHEUS}"
144+
},
145+
"editorMode": "code",
146+
"expr": "sum(gitpod_ws_daemon_netlimit_connections_dropped_packets{node=~\"$node\", workspace=~\"$workspace\"}) by (node, workspace)\n",
147+
"interval": "",
148+
"legendFormat": "{{workspace}}",
149+
"range": true,
150+
"refId": "A"
151+
},
152+
{
153+
"datasource": {
154+
"type": "prometheus",
155+
"uid": "${DS_PROMETHEUS}"
156+
},
157+
"editorMode": "builder",
158+
"expr": "",
159+
"hide": false,
160+
"legendFormat": "__auto",
161+
"range": true,
162+
"refId": "B"
163+
}
164+
],
165+
"title": "Dropped packets",
166+
"type": "timeseries"
167+
},
168+
{
169+
"datasource": {
170+
"type": "prometheus",
171+
"uid": "${DS_PROMETHEUS}"
172+
},
173+
"fieldConfig": {
174+
"defaults": {
175+
"color": {
176+
"mode": "palette-classic"
177+
},
178+
"custom": {
179+
"axisCenteredZero": false,
180+
"axisColorMode": "text",
181+
"axisLabel": "",
182+
"axisPlacement": "auto",
183+
"barAlignment": 0,
184+
"drawStyle": "line",
185+
"fillOpacity": 0,
186+
"gradientMode": "none",
187+
"hideFrom": {
188+
"legend": false,
189+
"tooltip": false,
190+
"viz": false
191+
},
192+
"lineInterpolation": "linear",
193+
"lineWidth": 1,
194+
"pointSize": 5,
195+
"scaleDistribution": {
196+
"type": "linear"
197+
},
198+
"showPoints": "auto",
199+
"spanNulls": false,
200+
"stacking": {
201+
"group": "A",
202+
"mode": "none"
203+
},
204+
"thresholdsStyle": {
205+
"mode": "off"
206+
}
207+
},
208+
"mappings": [],
209+
"thresholds": {
210+
"mode": "absolute",
211+
"steps": [
212+
{
213+
"color": "green",
214+
"value": null
215+
},
216+
{
217+
"color": "red",
218+
"value": 80
219+
}
220+
]
221+
}
222+
},
223+
"overrides": []
224+
},
225+
"gridPos": {
226+
"h": 9,
227+
"w": 12,
228+
"x": 12,
229+
"y": 0
230+
},
231+
"id": 4,
232+
"options": {
233+
"legend": {
234+
"calcs": [],
235+
"displayMode": "list",
236+
"placement": "bottom",
237+
"showLegend": true
238+
},
239+
"tooltip": {
240+
"mode": "single",
241+
"sort": "none"
242+
}
243+
},
244+
"targets": [
245+
{
246+
"datasource": {
247+
"type": "prometheus",
248+
"uid": "${DS_PROMETHEUS}"
249+
},
250+
"editorMode": "code",
251+
"expr": "sum(gitpod_ws_daemon_netlimit_connections_dropped_bytes{node=~\"$node\", workspace=~\"$workspace\"}) by (node, workspace)",
252+
"legendFormat": "{{workspace}}",
253+
"range": true,
254+
"refId": "A"
255+
}
256+
],
257+
"title": "Dropped bytes",
258+
"type": "timeseries"
259+
}
260+
],
261+
"schemaVersion": 37,
262+
"style": "dark",
263+
"tags": [],
264+
"templating": {
265+
"list": [
266+
{
267+
"current": {
268+
"selected": false,
269+
"text": "prometheus",
270+
"value": "prometheus"
271+
},
272+
"hide": 0,
273+
"includeAll": false,
274+
"multi": false,
275+
"name": "datasource",
276+
"options": [],
277+
"query": "prometheus",
278+
"refresh": 1,
279+
"regex": "",
280+
"skipUrlSync": false,
281+
"type": "datasource"
282+
},
283+
{
284+
"current": {},
285+
"datasource": {
286+
"type": "prometheus",
287+
"uid": "${DS_PROMETHEUS}"
288+
},
289+
"definition": "label_values(kube_node_labels{nodepool=\"workspace-pool\"}, node)",
290+
"hide": 0,
291+
"includeAll": false,
292+
"label": "Node",
293+
"multi": false,
294+
"name": "node",
295+
"options": [],
296+
"query": {
297+
"query": "label_values(kube_node_labels{nodepool=\"workspace-pool\"}, node)",
298+
"refId": "StandardVariableQuery"
299+
},
300+
"refresh": 2,
301+
"regex": "",
302+
"skipUrlSync": false,
303+
"sort": 1,
304+
"type": "query"
305+
},
306+
{
307+
"current": {},
308+
"datasource": {
309+
"type": "prometheus",
310+
"uid": "${DS_PROMETHEUS}"
311+
},
312+
"definition": "label_values(kube_pod_labels{component=\"workspace\"}, pod)",
313+
"hide": 0,
314+
"includeAll": true,
315+
"label": "Workspace",
316+
"multi": false,
317+
"name": "workspace",
318+
"options": [],
319+
"query": {
320+
"query": "label_values(kube_pod_labels{component=\"workspace\"}, pod)",
321+
"refId": "StandardVariableQuery"
322+
},
323+
"refresh": 2,
324+
"regex": "",
325+
"skipUrlSync": false,
326+
"sort": 1,
327+
"type": "query"
328+
}
329+
]
330+
},
331+
"time": {
332+
"from": "now-5m",
333+
"to": "now"
334+
},
335+
"timepicker": {},
336+
"timezone": "",
337+
"title": "Network limiting",
338+
"uid": "-q-ZCsW4z",
339+
"version": 24,
340+
"weekStart": ""
341+
}

0 commit comments

Comments
 (0)