Skip to content

Commit

Permalink
Support scraping outbound traffic stats. Fix #7.
Browse files Browse the repository at this point in the history
  • Loading branch information
wi1dcard committed Sep 15, 2020
1 parent a6e382d commit 171e4df
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 10 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ Firstly, you will need to make sure the API and statistics related features have
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
"statsInboundDownlink": true,
"statsOutboundUplink": true,
"statsOutboundDownlink": true
}
},
"inbounds": [
Expand Down Expand Up @@ -207,6 +209,8 @@ For users who do not really care about the internal changes, but only need a map
| :---------------------------------------- | :-------------------------------------------------------------------------- |
| `inbound>>>tag-name>>>traffic>>>uplink` | `v2ray_traffic_uplink_bytes_total{dimension="inbound",target="tag-name"}` |
| `inbound>>>tag-name>>>traffic>>>downlink` | `v2ray_traffic_downlink_bytes_total{dimension="inbound",target="tag-name"}` |
| `outbound>>>tag-name>>>traffic>>>uplink` | `v2ray_traffic_uplink_bytes_total{dimension="outbound",target="tag-name"}` |
| `outbound>>>tag-name>>>traffic>>>downlink` | `v2ray_traffic_downlink_bytes_total{dimension="outbound",target="tag-name"}` |
| `user>>>user-email>>traffic>>>uplink` | `v2ray_traffic_uplink_bytes_total{dimension="user",target="user-email"}` |
| `user>>>user-email>>>traffic>>>downlink` | `v2ray_traffic_downlink_bytes_total{dimension="user",target="user-email"}` |
| ... | ... |
Expand Down
213 changes: 204 additions & 9 deletions dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"gnetId": null,
"graphTooltip": 0,
"id": null,
"iteration": 1594391256464,
"iteration": 1600162188699,
"links": [],
"panels": [
{
Expand Down Expand Up @@ -924,6 +924,7 @@
"dashLength": 10,
"dashes": false,
"datasource": "${DS_PROMETHEUS}",
"decimals": null,
"fieldConfig": {
"defaults": {
"custom": {}
Expand All @@ -939,11 +940,13 @@
"y": 13
},
"hiddenSeries": false,
"id": 13,
"id": 12,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"hideEmpty": false,
"hideZero": false,
"max": true,
"min": false,
"rightSide": true,
Expand All @@ -967,7 +970,7 @@
"steppedLine": false,
"targets": [
{
"expr": "irate(v2ray_traffic_downlink_bytes_total{job=~\"$job\",instance=~\"$instance\",dimension=\"user\"}[5m])",
"expr": "irate(v2ray_traffic_uplink_bytes_total{job=~\"$job\",instance=~\"$instance\",dimension=\"inbound\"}[5m])",
"interval": "",
"legendFormat": "{{target}}",
"refId": "A"
Expand All @@ -977,7 +980,7 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Download Speed of Users",
"title": "Upload Speed of Inbounds",
"tooltip": {
"shared": true,
"sort": 0,
Expand Down Expand Up @@ -1020,7 +1023,6 @@
"dashLength": 10,
"dashes": false,
"datasource": "${DS_PROMETHEUS}",
"decimals": null,
"fieldConfig": {
"defaults": {
"custom": {}
Expand All @@ -1036,7 +1038,104 @@
"y": 19
},
"hiddenSeries": false,
"id": 12,
"id": 32,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"dataLinks": []
},
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "irate(v2ray_traffic_downlink_bytes_total{job=~\"$job\",instance=~\"$instance\",dimension=\"outbound\"}[5m])",
"interval": "",
"legendFormat": "{{target}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Download Speed of Outbounds",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "Bps",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": false
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "${DS_PROMETHEUS}",
"decimals": null,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 6,
"w": 12,
"x": 12,
"y": 19
},
"hiddenSeries": false,
"id": 33,
"legend": {
"alignAsTable": true,
"avg": true,
Expand Down Expand Up @@ -1066,7 +1165,7 @@
"steppedLine": false,
"targets": [
{
"expr": "irate(v2ray_traffic_uplink_bytes_total{job=~\"$job\",instance=~\"$instance\",dimension=\"inbound\"}[5m])",
"expr": "irate(v2ray_traffic_uplink_bytes_total{job=~\"$job\",instance=~\"$instance\",dimension=\"outbound\"}[5m])",
"interval": "",
"legendFormat": "{{target}}",
"refId": "A"
Expand All @@ -1076,7 +1175,103 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Upload Speed of Inbounds",
"title": "Upload Speed of Outbounds",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "Bps",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": false
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "${DS_PROMETHEUS}",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 6,
"w": 12,
"x": 0,
"y": 25
},
"hiddenSeries": false,
"id": 13,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"dataLinks": []
},
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "irate(v2ray_traffic_downlink_bytes_total{job=~\"$job\",instance=~\"$instance\",dimension=\"user\"}[5m])",
"interval": "",
"legendFormat": "{{target}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Download Speed of Users",
"tooltip": {
"shared": true,
"sort": 0,
Expand Down Expand Up @@ -1131,7 +1326,7 @@
"h": 6,
"w": 12,
"x": 12,
"y": 19
"y": 25
},
"hiddenSeries": false,
"id": 14,
Expand Down

0 comments on commit 171e4df

Please sign in to comment.