Feature wanted: 增加对每个访问目标URL的流量统计
deanmax opened this issue · 10 comments
这个只是单连接,clash dashboard 也有
我的意思是,是否方便在metrics里加入url label:
比如 {"down":1434134,"type":"traffic","up":3724,"url":"www.google.com"}
@Dreamacro 作者你好 CLASH_TOKEN的值应该就是secret吧?
但是似乎我尝试直接访问
curl http://10.0.0.1:9090/traffic?token=123456 提示未授权 我看收集器就是这么连的ws 所以也失败了
换成文档写的方式就可以
curl -v -H "Authorization: Bearer 123456" http://10.0.0.1:9090/traffic
所以是?
@luckyyyyy 只有 websocket 连接支持 query token,http 是不支持的
@luckyyyyy 只有 websocket 连接支持 query token,http 是不支持的
原来如此,晚些我换ws再验证一下,我现在裸跑效果挺好的,链路收集都很正常,昨天试了很多次加上token都不行。
@deanmax 你可以自己添加面板实现这个功能,仓库里只是个参考
添加面板简单,只要metrics有支持按url的流量统计即可(现在应该还没有可以用的metrics)
I don't think there is a metric that supports exporting statistical information about a specific site/node/interface/user. What I get from ws://$CLASH_HOST/traffic?token=$CLASH_TOKEN
is only the current upload and download speed.
Unlike V2ray's stats api which can output the statistical usage of each interface:
name: "inbound>>>ss>>>traffic>>>downlink"
value: 1704
name: "inbound>>>ss>>>traffic>>>uplink"
value: 2276
name: "user>>>u9@ss>>>traffic>>>uplink"
value: 1776
name: "user>>>u9@ss>>>traffic>>>downlink"
value: 1368
name: "user>>>u3@ws>>>traffic>>>uplink"
value: 2810759
name: "user>>>u3@ws>>>traffic>>>downlink"
value: 126944108
What I get when accessing ws://$CLASH_HOST/profile/tracing?token=$CLASH_TOKEN
:
{
"answer": "xx.xx.xx.xx",
"dnsType": "fakeip",
"duration": 5,
"id": "9a9axxxxxxxxxxxxxxx9a9a",
"name": "www.apple.com",
"qType": "AAAA",
"type": "DNSRequest"
},
{
"duration": 50000,
"id": "4b4bxxxxxxxxxxxxxxx4b4b",
"metadata": {
"network": "tcp",
"type": "TUN",
"sourceIP": "198.18.0.1",
"destinationIP": "xx.xx.xx.xx",
"sourcePort": "40001",
"destinationPort": "443",
"host": "www.apple.com",
"dnsMode": "fake-ip",
"processPath": "ProcessName"
},
"payload": "",
"proxy": "PROXY",
"rule": "Match",
"type": "RuleMatch"
},
{
"address": "www.apple.com:443",
"chain": [
"NodeName",
"PROXY"
],
"duration": 150000,
"host": "www.apple.com",
"id": "4b4bxxxxxxxxxxxxxxx4b4b",
"proxy": "NodeName",
"type": "ProxyDial"
}
I can already get most of the metrics, with the exception of dial-up time, from clash.log
and import them into Grafana using Promtail. The data from clash.log
:
time="2022-07-22T00:00:00" level=debug msg="[Process] www.apple.com from process /ProcessName"
time="2022-07-22T00:00:00" level=info msg="[TCP] 198.18.0.1:40001 --> www.apple.com:443 match RuleSet(my-rule-set) using PROXY[NodeName]"