Skip to content

Commit 5c93b51

Browse files
authored
Pattern matching and Listener optimisations (#14)
1 parent 6080a5b commit 5c93b51

File tree

7 files changed

+326
-131
lines changed

7 files changed

+326
-131
lines changed

config/runtime.exs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ external_relay_ip =
106106
:error -> external_listen_ip
107107
end
108108

109+
listener_count =
110+
case System.fetch_env("LISTENER_COUNT") do
111+
{:ok, count} ->
112+
count = String.to_integer(count)
113+
if count <= 0, do: raise("LISTENER_COUNT must be greater than 0")
114+
count
115+
116+
:error ->
117+
System.schedulers_online()
118+
end
119+
109120
# AuthProvider/credentials configuration
110121
config :rel,
111122
auth_provider_ip:
@@ -135,3 +146,7 @@ config :rel,
135146
config :rel,
136147
auth_secret: :crypto.strong_rand_bytes(64),
137148
nonce_secret: :crypto.strong_rand_bytes(64)
149+
150+
# Other
151+
config :rel,
152+
listener_count: listener_count

grafana/provisioning/dashboards/rel_metrics.json

Lines changed: 164 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"editable": true,
1919
"fiscalYearStartMonth": 0,
2020
"graphTooltip": 0,
21-
"id": 2,
2221
"links": [],
2322
"liveNow": false,
2423
"panels": [
@@ -114,10 +113,23 @@
114113
"exemplar": false,
115114
"expr": "rate(turn_listener_client_inbound_traffic_total_bytes[$__interval]) * 8",
116115
"instant": false,
117-
"legendFormat": "Clients -> Listener",
116+
"legendFormat": "Clients -> Listener {{ listener_id }}",
118117
"range": true,
119118
"refId": "client_listener"
120119
},
120+
{
121+
"datasource": {
122+
"type": "prometheus",
123+
"uid": "PBFA97CFB590B2093"
124+
},
125+
"editorMode": "builder",
126+
"expr": "sum(rate(turn_listener_client_inbound_traffic_total_bytes[$__interval])) * 8",
127+
"hide": false,
128+
"instant": false,
129+
"legendFormat": "Clients -> Listener (Total)",
130+
"range": true,
131+
"refId": "client_listener_total"
132+
},
121133
{
122134
"datasource": {
123135
"type": "prometheus",
@@ -136,6 +148,130 @@
136148
"transparent": true,
137149
"type": "timeseries"
138150
},
151+
{
152+
"datasource": {
153+
"type": "prometheus",
154+
"uid": "PBFA97CFB590B2093"
155+
},
156+
"fieldConfig": {
157+
"defaults": {
158+
"color": {
159+
"mode": "palette-classic"
160+
},
161+
"custom": {
162+
"axisCenteredZero": false,
163+
"axisColorMode": "series",
164+
"axisLabel": "",
165+
"axisPlacement": "auto",
166+
"barAlignment": 0,
167+
"drawStyle": "line",
168+
"fillOpacity": 0,
169+
"gradientMode": "none",
170+
"hideFrom": {
171+
"legend": false,
172+
"tooltip": false,
173+
"viz": false
174+
},
175+
"lineInterpolation": "smooth",
176+
"lineWidth": 1,
177+
"pointSize": 5,
178+
"scaleDistribution": {
179+
"type": "linear"
180+
},
181+
"showPoints": "auto",
182+
"spanNulls": false,
183+
"stacking": {
184+
"group": "A",
185+
"mode": "none"
186+
},
187+
"thresholdsStyle": {
188+
"mode": "off"
189+
}
190+
},
191+
"mappings": [],
192+
"thresholds": {
193+
"mode": "absolute",
194+
"steps": [
195+
{
196+
"color": "green",
197+
"value": null
198+
},
199+
{
200+
"color": "red",
201+
"value": 80
202+
}
203+
]
204+
}
205+
},
206+
"overrides": []
207+
},
208+
"gridPos": {
209+
"h": 10,
210+
"w": 24,
211+
"x": 0,
212+
"y": 11
213+
},
214+
"id": 7,
215+
"options": {
216+
"legend": {
217+
"calcs": [
218+
"lastNotNull",
219+
"max",
220+
"mean"
221+
],
222+
"displayMode": "table",
223+
"placement": "bottom",
224+
"showLegend": true
225+
},
226+
"tooltip": {
227+
"mode": "single",
228+
"sort": "none"
229+
}
230+
},
231+
"targets": [
232+
{
233+
"datasource": {
234+
"type": "prometheus",
235+
"uid": "PBFA97CFB590B2093"
236+
},
237+
"editorMode": "builder",
238+
"expr": "rate(turn_listener_client_inbound_traffic_packets_total[$__interval])",
239+
"instant": false,
240+
"legendFormat": "Clients -> Listener {{listener_id}}",
241+
"range": true,
242+
"refId": "client_listener"
243+
},
244+
{
245+
"datasource": {
246+
"type": "prometheus",
247+
"uid": "PBFA97CFB590B2093"
248+
},
249+
"editorMode": "builder",
250+
"expr": "sum(rate(turn_listener_client_inbound_traffic_packets_total[$__interval]))",
251+
"hide": false,
252+
"instant": false,
253+
"legendFormat": "Client -> Listener (Total)",
254+
"range": true,
255+
"refId": "client_listener_total"
256+
},
257+
{
258+
"datasource": {
259+
"type": "prometheus",
260+
"uid": "PBFA97CFB590B2093"
261+
},
262+
"editorMode": "builder",
263+
"expr": "rate(turn_allocations_peer_inbound_traffic_packets_total[$__interval])",
264+
"hide": false,
265+
"instant": false,
266+
"legendFormat": "Peers -> Allocation_handlers",
267+
"range": true,
268+
"refId": "peers_allocation"
269+
}
270+
],
271+
"title": "Packets",
272+
"transparent": true,
273+
"type": "timeseries"
274+
},
139275
{
140276
"datasource": {
141277
"type": "prometheus",
@@ -198,7 +334,7 @@
198334
"h": 9,
199335
"w": 24,
200336
"x": 0,
201-
"y": 11
337+
"y": 21
202338
},
203339
"id": 3,
204340
"interval": "5",
@@ -331,7 +467,7 @@
331467
"h": 9,
332468
"w": 24,
333469
"x": 0,
334-
"y": 20
470+
"y": 30
335471
},
336472
"id": 6,
337473
"options": {
@@ -353,35 +489,28 @@
353489
"uid": "PBFA97CFB590B2093"
354490
},
355491
"editorMode": "code",
356-
"expr": "100 - (rate(node_cpu_seconds_total{job=\"node\",mode=\"idle\"}[$__rate_interval]) * 100)",
492+
"expr": "100 - (rate(node_cpu_seconds_total{job=\"node\",mode=\"idle\"}[$__interval]) * 100)",
357493
"instant": false,
358494
"legendFormat": "Core {{cpu}}",
359495
"range": true,
360496
"refId": "cpu"
361-
}
362-
],
363-
"title": "CPU usage",
364-
"transformations": [
497+
},
365498
{
366-
"id": "calculateField",
367-
"options": {
368-
"mode": "reduceRow",
369-
"reduce": {
370-
"include": [
371-
"Core 0",
372-
"Core 1",
373-
"Core 2",
374-
"Core 3",
375-
"Core 4",
376-
"Core 5",
377-
"Core 6",
378-
"Core 7"
379-
],
380-
"reducer": "sum"
381-
}
382-
}
499+
"datasource": {
500+
"type": "prometheus",
501+
"uid": "PBFA97CFB590B2093"
502+
},
503+
"editorMode": "code",
504+
"expr": "sum(100 - (rate(node_cpu_seconds_total{job=\"node\",mode=\"idle\"}[$__interval]) * 100))",
505+
"hide": false,
506+
"instant": false,
507+
"legendFormat": "Total",
508+
"range": true,
509+
"refId": "cpu_total"
383510
}
384511
],
512+
"title": "CPU usage",
513+
"transformations": [],
385514
"transparent": true,
386515
"type": "timeseries"
387516
},
@@ -444,10 +573,10 @@
444573
"overrides": []
445574
},
446575
"gridPos": {
447-
"h": 10,
448-
"w": 12,
576+
"h": 9,
577+
"w": 24,
449578
"x": 0,
450-
"y": 29
579+
"y": 39
451580
},
452581
"id": 4,
453582
"options": {
@@ -539,10 +668,10 @@
539668
"overrides": []
540669
},
541670
"gridPos": {
542-
"h": 10,
543-
"w": 12,
544-
"x": 12,
545-
"y": 29
671+
"h": 8,
672+
"w": 24,
673+
"x": 0,
674+
"y": 48
546675
},
547676
"id": 5,
548677
"options": {
@@ -597,13 +726,13 @@
597726
"list": []
598727
},
599728
"time": {
600-
"from": "now-5m",
729+
"from": "now-1h",
601730
"to": "now"
602731
},
603732
"timepicker": {},
604733
"timezone": "",
605734
"title": "Rel metrics",
606735
"uid": "f89914d6-5064-454e-bfb9-128f69816c36",
607-
"version": 6,
736+
"version": 1,
608737
"weekStart": ""
609738
}

0 commit comments

Comments
 (0)