之前为了jenkins加速npm/pip/mvn/composer构建包和docker镜像而在服务器上部署clash,当时没注意到作者居然还有个clash-tracing仓库,最近看到微信有相关的推文,遂倒腾一下介入到grafana

clash premium部署

clash 和 clash premium作者是同一个,后者拥有更多功能,之前部署时用clash,现在需要改为clash premium

快速安装

可参考仓库:https://github.com/Kr328/clash-premium-installer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[root@localhost ~]# git clone https://github.com/Kr328/clash-premium-installer
[root@localhost ~]# cd clash-premium-installer/
[root@localhost clash-premium-installer]# yum install jq -y
[root@localhost clash-premium-installer]# ./installer.sh install
[root@localhost clash-premium-installer]# systemctl daemon-reload
[root@localhost clash-premium-installer]# systemctl cat clash
# /etc/systemd/system/clash.service
[Unit]
Description=A rule based proxy tunnel
After=network-online.target nftables.service iptabels.service

[Service]
Type=simple
LimitNOFILE=65535
ExecStartPre=/usr/lib/clash/setup-cgroup.sh
ExecStart=/usr/bin/bypass-proxy /usr/bin/clash -d /srv/clash

[Install]
WantedBy=multi-user.target
[root@localhost clash-premium-installer]# systemctl restart clash
# 自动安装会安装在/srv/clash目录内,读者自行将订阅配置文件放到此处
# 此时再次打开clash的ui界面,左下角提示版本已是clash-premium

clash开启tracing

用上面自动安装脚本安装在配置文件中加入以下配置

1
2
profile:
tracing: true

clash-tracing部署

clash-tracing:https://github.com/Dreamacro/clash-tracing

1
2
3
4
5
6
7
8
9
10
11
[root@blog ~]# cd /data
[root@blog data]# git clone https://github.com/Dreamacro/clash-tracing
[root@blog data]# cd clash-tracing
[root@blog clash-tracing]# ll
total 8
-rw-r--r-- 1 root root 1811 Jul 29 17:59 docker-compose.yml
drwxr-xr-x 4 root root 40 Jul 29 12:48 grafana
drwxr-xr-x 2 root root 25 Jul 29 12:48 loki
-rw-r--r-- 1 root root 234 Jul 29 12:48 README.md
drwxr-xr-x 2 root root 28 Jul 29 12:48 screenshot
drwxr-xr-x 2 root root 25 Jul 29 20:02 vector

vector数据处理配置

vector这个工具博主也是才知道,这个东西看起来功能很强大,用来做etl似乎是个不错的选择,卖个坑后续找个时间调研下

vector数据处理并发送给loki

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
[root@blog clash-tracing]# cat vector/vector.toml
[sources.mixed]
type = "socket"
address = "0.0.0.0:9000"
mode = "tcp"
decoding.codec = "json"
host_key = "vector-server"

[transforms.traffic-input]
type = "filter"
inputs = [ "mixed" ]
condition = "exists(.up)"

[transforms.tracing-input]
type = "filter"
inputs = [ "mixed" ]
condition = "!exists(.up)"

[transforms.traffic]
type = "remap"
inputs = [ "traffic-input" ]
source = """
.type = "traffic"
del(.source_type)"""

[transforms.tracing]
type = "remap"
inputs = [ "tracing-input" ]
source = """
.type = downcase!(.type)
del(.source_type)
if exists(.@metadata) {
.metadata_dstip = .metadata.destinationIP
.metadata_dstport = .metadata.destinationPort
.metadata_host = .metadata.host
.metadata_network = .metadata.network
.metadata_srcip = .metadata.sourceIP
.metadata_srcport = .metadata.sourcePort
.metadata_type = .metadata.type
.metadata_dnsmode = .metadata.dnsMode
del(.@metadata)
}
"""
[sinks.loki]
type = "loki"
inputs = [ "traffic", "tracing" ]
# 我的loki服务器
endpoint = "http://192.168.44.170:3100"
encoding.codec = "json"
labels.type = "{{ type }}"

上面注意有坑:作者仓库的vector.toml中的sources里的host_key配置为空,这会导致loki接受到的数据

1
{"":"192.168.0.3","address":"alive.github.com:443","chain":["美国5cn-us","代理"],"duration":38265,"host":"alive.github.com","id":"fe79c013-c224-4468-b523-a2c66a9d9191","port":49690,"proxy":"美国5cn-us","type":"proxydial"}

注意第一个key居然为空,这个就是vector中配置host_key,而此时我们grafana再做一次json解析就会报错

1
err while creating labelset for {="192.168.0.3", address="alive.github.com:443", duration="38265", host="alive.github.com", id="fe79c013-c224-4468-b523-a2c66a9d9191", port="49690", proxy="美国5cn-us", type="proxydial", type_extracted="proxydial"}: 1:2: parse error: unexpected "=" in label set, expected identifier or "}"

所以的话我们需要配置下vector中的sources块内的host_key

由于这个仓库里的docker-compose文件里已有grafana和loki,读者可以自行根据需要调整。而博主这里已经有loki和grafana,所以就不必在此处部署,此时博主的docker-compose.yaml

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
[root@blog clash-tracing]# cat docker-compose.yml
version: '3'
services:
# loki:
# image: grafana/loki:2.6.1
# container_name: loki
# restart: always
# user: root
# volumes:
# - ./loki/data:/loki
# - ./loki/config.yaml:/etc/loki/local-config.yaml
# grafana:
# image: grafana/grafana-oss:latest
# container_name: grafana
# restart: always
# user: root
# volumes:
# - ./grafana/data:/var/lib/grafana
# - ./grafana/panels:/etc/dashboards
# - ./grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards
# - ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
# ports:
# - "3000:3000"
vector:
image: timberio/vector:0.X-alpine
container_name: vector
restart: always
volumes:
- ./vector/vector.toml:/etc/vector/vector.toml
traffic_scraper:
image: vi0oss/websocat:0.10.0
container_name: traffic_scraper
restart: always
command: -v --autoreconnect-delay-millis 15000 autoreconnect:ws://${CLASH_HOST}/traffic?token=${CLASH_TOKEN} autoreconnect:tcp:vector:9000
depends_on:
- vector
tracing_scraper:
image: vi0oss/websocat:0.10.0
container_name: tracing_scraper
restart: always
command: -v --autoreconnect-delay-millis 15000 autoreconnect:ws://${CLASH_HOST}/profile/tracing?token=${CLASH_TOKEN} autoreconnect:tcp:vector:9000
depends_on:
- vector

# 配置.env文件,和docker-compse.yml同级目录
# CLASH_TOKEN配置看读者自己的clash配置文件有没有配置secret参数,没有配置则留空
[root@blog clash-tracing]# cat .env
CLASH_HOST="192.168.44.150:9090"
CLASH_TOKEN="abcdefg"

启动采集和中转服务

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
# 启动服务
[root@blog clash-tracing]# docker-compose up -d
[+] Running 4/4
⠿ Network clash-tracing_default Created 0.1s
⠿ Container vector Started 0.5s
⠿ Container tracing_scraper Started 1.2s
⠿ Container traffic_scraper Started 1.2s

# 这两个采集服务没有错误日志即可
[root@blog clash-tracing]# docker logs tracing_scraper
websocat: It is recommended to either set --binary or --text explicitly
[INFO websocat::lints] Auto-inserting the line mode
[INFO websocat::net_peer] Resolving hostname to IP addresses
[INFO websocat::net_peer] Got IP: 172.29.0.2:9000
[INFO websocat::ws_client_peer] get_ws_client_peer
[INFO websocat::net_peer] Connected to TCP 172.29.0.2:9000
[INFO websocat::ws_client_peer] Connected to ws
[root@blog clash-tracing]#
[root@blog clash-tracing]# docker logs traffic_scraper
websocat: It is recommended to either set --binary or --text explicitly
[INFO websocat::lints] Auto-inserting the line mode
[INFO websocat::net_peer] Resolving hostname to IP addresses
[INFO websocat::net_peer] Got IP: 172.29.0.2:9000
[INFO websocat::ws_client_peer] get_ws_client_peer
[INFO websocat::net_peer] Connected to TCP 172.29.0.2:9000
[INFO websocat::ws_client_peer] Connected to ws

grafana配置

调整dashboard文件,因为作者提供的dashboard文件中使用的datasource是default,而博主这里的default是prometheus,在调整这个面版datasource时会导致query语句丢失。。。裂开,最后调整了下

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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "loki",
"uid": "eZIPA-pVk"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 16,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 6,
"x": 0,
"y": 0
},
"id": 6,
"options": {
"displayMode": "gradient",
"minVizHeight": 10,
"minVizWidth": 0,
"orientation": "horizontal",
"reduceOptions": {
"calcs": [],
"fields": "",
"values": true
},
"showUnfilled": true,
"text": {}
},
"pluginVersion": "9.2.5",
"targets": [
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"expr": "{type=\"proxydial\"}",
"legendFormat": "{{host}}",
"refId": "A",
"resolution": 1
}
],
"title": "域名访问次数",
"transformations": [
{
"id": "extractFields",
"options": {
"replace": true,
"source": "Line"
}
},
{
"id": "groupBy",
"options": {
"fields": {
"host": {
"aggregations": [],
"operation": "groupby"
},
"id": {
"aggregations": [
"count"
],
"operation": "aggregate"
}
}
}
},
{
"id": "sortBy",
"options": {
"fields": {},
"sort": [
{
"desc": true,
"field": "id (count)"
}
]
}
}
],
"type": "bargauge"
},
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"custom": {
"align": "auto",
"displayMode": "color-text",
"filterable": true,
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "duration"
},
"properties": [
{
"id": "unit",
"value": "µs"
},
{
"id": "custom.displayMode",
"value": "gradient-gauge"
}
]
},
{
"matcher": {
"id": "byName",
"options": "proxy"
},
"properties": [
{
"id": "custom.width",
"value": 120
}
]
},
{
"matcher": {
"id": "byName",
"options": "address"
},
"properties": [
{
"id": "custom.width",
"value": 340
}
]
}
]
},
"gridPos": {
"h": 10,
"w": 11,
"x": 6,
"y": 0
},
"id": 8,
"options": {
"footer": {
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"frameIndex": 2,
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "duration"
}
]
},
"pluginVersion": "9.2.5",
"targets": [
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "{type=\"proxydial\"} json",
"legendFormat": "",
"maxLines": 20,
"queryType": "range",
"refId": "A"
}
],
"title": "代理时延",
"transformations": [
{
"id": "extractFields",
"options": {
"format": "auto",
"replace": false,
"source": "Line"
}
},
{
"id": "organize",
"options": {
"excludeByName": {
"Field": true,
"First": true,
"Line": true,
"Time": true,
"Value": true,
"address": false,
"chain": true,
"duration": false,
"error": true,
"host": true,
"id": true,
"labels": true,
"localhost": true,
"port": true,
"proxy": false,
"tsNs": true,
"type": true,
"type_extracted": true,
"vector-server": true
},
"indexByName": {
"Value": 7,
"address": 0,
"chain": 1,
"duration": 3,
"host": 4,
"id": 5,
"port": 8,
"proxy": 2,
"type": 6
},
"renameByName": {
"Value": "",
"chain": "",
"proxy": ""
}
}
}
],
"type": "table"
},
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "continuous-GrYlRd"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 7,
"x": 17,
"y": 0
},
"id": 10,
"options": {
"displayMode": "gradient",
"minVizHeight": 10,
"minVizWidth": 0,
"orientation": "horizontal",
"reduceOptions": {
"calcs": [],
"fields": "",
"values": true
},
"showUnfilled": true,
"text": {}
},
"pluginVersion": "9.2.5",
"targets": [
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"expr": "{type=\"rulematch\"}",
"refId": "A"
}
],
"title": "局域网访问",
"transformations": [
{
"id": "filterFieldsByName",
"options": {
"include": {}
}
},
{
"id": "extractFields",
"options": {
"format": "kvp",
"replace": true,
"source": "Line"
}
},
{
"id": "groupBy",
"options": {
"fields": {
"id": {
"aggregations": [
"count"
],
"operation": "aggregate"
},
"metadata_srcip": {
"aggregations": [
"count"
],
"operation": "groupby"
},
"sourceIP": {
"aggregations": [],
"operation": "groupby"
}
}
}
},
{
"id": "sortBy",
"options": {
"fields": {},
"sort": [
{
"desc": true,
"field": "id (count)"
}
]
}
}
],
"type": "bargauge"
},
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "smooth",
"lineWidth": 1,
"pointSize": 6,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "µs"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 7,
"x": 17,
"y": 6
},
"id": 12,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": false
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"expr": "avg_over_time({type=\"rulematch\"} json unwrap duration [$__range]) by (type)",
"refId": "A"
}
],
"title": "规则匹配速度",
"transformations": [],
"type": "timeseries"
},
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 4,
"x": 0,
"y": 10
},
"id": 4,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"sum"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "9.2.5",
"targets": [
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"expr": "sum by (type) (sum_over_time({type=\"traffic\"} json unwrap down [$__interval]))",
"legendFormat": "",
"refId": "A"
},
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"expr": "sum by (type) (sum_over_time({type=\"traffic\"} json unwrap up [$__interval]))",
"hide": false,
"refId": "B"
}
],
"title": "流量统计",
"transformations": [
{
"id": "calculateField",
"options": {
"mode": "reduceRow",
"reduce": {
"include": [
"{type=\"traffic\"}"
],
"reducer": "sum"
},
"replaceFields": true
}
}
],
"type": "stat"
},
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "µs"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 6,
"x": 4,
"y": 10
},
"id": 16,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"expr": "avg_over_time({type=\"dnsrequest\"} json unwrap duration [$__range]) by (qType)",
"legendFormat": "{{qType}}",
"refId": "A"
}
],
"title": "DNS 平均查询时间",
"type": "timeseries"
},
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "smooth",
"lineWidth": 1,
"pointSize": 6,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "µs"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 7,
"x": 10,
"y": 10
},
"id": 14,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"expr": "avg_over_time({type=\"proxydial\"} json unwrap duration [$__range]) by (proxy)",
"legendFormat": "{{proxy}}",
"refId": "A"
}
],
"title": "代理 Dial 时间",
"transformations": [],
"type": "timeseries"
},
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "smooth",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "binBps"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 7,
"x": 17,
"y": 12
},
"id": 2,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"expr": "avg by (type) (sum_over_time({type=\"traffic\"} json unwrap up [$__interval]))",
"legendFormat": "Upload",
"refId": "A"
},
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"expr": "avg by (type) (sum_over_time({type=\"traffic\"} json unwrap down [$__interval]))",
"hide": false,
"legendFormat": "Download",
"refId": "B"
}
],
"title": "实时流量",
"type": "timeseries"
},
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "continuous-blues"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 4,
"x": 0,
"y": 14
},
"id": 17,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"count"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "9.2.5",
"targets": [
{
"datasource": {
"type": "loki",
"uid": "${datasource}"
},
"expr": "sum by (type) (rate({type=\"dnsrequest\"}[$__interval]))",
"legendFormat": "",
"refId": "A"
}
],
"title": "DNS 查询",
"transformations": [],
"type": "stat"
}
],
"refresh": false,
"schemaVersion": 37,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
"current": {
"selected": false,
"text": "Loki",
"value": "Loki"
},
"description": "datasource",
"hide": 0,
"includeAll": false,
"label": "datasource",
"multi": false,
"name": "datasource",
"options": [],
"query": "loki",
"queryValue": "",
"refresh": 1,
"regex": "/.*/",
"skipUrlSync": false,
"type": "datasource"
}
]
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Clash",
"uid": "pOXPjK-7z",
"version": 8,
"weekStart": ""
}

图例