Clarify VPN and Direct traffic metrics in Grafana dashboard
Build and Deploy Gateway / build-and-push (push) Successful in 31s
Build and Deploy Gateway / deploy (push) Successful in 7s

This commit is contained in:
2026-09-01 07:01:26 +03:00
parent 76a99f098a
commit ab14fc979e
8 changed files with 316 additions and 91 deletions
+206 -65
View File
@@ -196,14 +196,14 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "Наблюдённые sing-box байты для выбранных устройств по фактически выбранному выходу. Direct IPv4 мимо sing-box учитывается отдельно в технической детализации.",
"description": "Фактический выход выбранных устройств за период. VPN включает трафик, вошедший через Gateway и явно настроенный Proxy. Direct приблизительно объединяет логические байты sing-box и IPv4 L3 packet bytes Linux; точная разбивка остаётся в технической детализации.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"decimals": 1,
"noValue": "Нет трафика",
"noValue": "Нет данных",
"unit": "bytes"
},
"overrides": [
@@ -290,7 +290,7 @@
},
{
"editorMode": "code",
"expr": "sum(increase(harbor_device_singbox_tracked_bytes_total{device_id=~\"$device_id\", outbound=\"direct\"}[$__range])) > 0",
"expr": "((sum(increase(harbor_device_singbox_tracked_bytes_total{device_id=~\"$device_id\", outbound=\"direct\"}[$__range])) or vector(0)) + (sum(increase(harbor_device_direct_ipv4_packet_bytes_total{device_id=~\"$device_id\"}[$__range])) or vector(0))) > 0",
"instant": true,
"legendFormat": "Direct",
"range": false,
@@ -382,7 +382,73 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "Скорость трафика выбранных устройств. Окно усреднения адаптируется к масштабу времени; скачивание показано вверх, отправка — вниз. Это наблюдаемый Harbor трафик, а не скорость интернет-канала.",
"description": "Последняя применённая policy устройства по данным Prometheus: Direct или VPN. Это не маршрут каждого байта: устройство в Direct может одновременно использовать VPN через явно настроенный Harbor Proxy.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"options": {
"0": {
"color": "orange",
"index": 0,
"text": "Direct"
},
"1": {
"color": "green",
"index": 1,
"text": "VPN"
}
},
"type": "value"
}
],
"noValue": "Нет данных"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 16,
"x": 0,
"y": 5
},
"id": 17,
"options": {
"alignValue": "left",
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": false
},
"mergeValues": true,
"rowHeight": 0.9,
"showValue": "always",
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"editorMode": "code",
"expr": "max by (device_id) (harbor_device_applied_policy{device_id=~\"$device_id\"}) * on (device_id) group_left (name, ip) max by (device_id, name, ip) (harbor_device_info)",
"legendFormat": "{{name}} · {{ip}}",
"range": true,
"refId": "A"
}
],
"title": "Применённый режим",
"type": "state-timeline"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "Фактическая скорость по выходу выбранных устройств. VPN суммирует Gateway и Proxy. Direct приблизительно объединяет непересекающиеся sing-box и Linux IPv4 пути с разной byte semantics. Скачивание показано вверх, отправка вниз.",
"fieldConfig": {
"defaults": {
"color": {
@@ -414,14 +480,14 @@
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Скачивание"
"id": "byRegexp",
"options": "^VPN"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "blue",
"fixedColor": "green",
"mode": "fixed"
}
}
@@ -429,8 +495,8 @@
},
{
"matcher": {
"id": "byName",
"options": "Отправка"
"id": "byRegexp",
"options": "^Direct"
},
"properties": [
{
@@ -442,6 +508,21 @@
}
]
},
{
"matcher": {
"id": "byRegexp",
"options": "^Не определено"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "gray",
"mode": "fixed"
}
}
]
},
{
"matcher": {
"id": "byFrameRefID",
@@ -453,6 +534,30 @@
"value": "negative-Y"
}
]
},
{
"matcher": {
"id": "byFrameRefID",
"options": "D"
},
"properties": [
{
"id": "custom.transform",
"value": "negative-Y"
}
]
},
{
"matcher": {
"id": "byFrameRefID",
"options": "F"
},
"properties": [
{
"id": "custom.transform",
"value": "negative-Y"
}
]
}
]
},
@@ -460,7 +565,7 @@
"h": 12,
"w": 16,
"x": 0,
"y": 5
"y": 9
},
"id": 3,
"options": {
@@ -482,20 +587,48 @@
"targets": [
{
"editorMode": "code",
"expr": "sum(rate(harbor_device_traffic_bytes_total{device_id=~\"$device_id\", direction=\"download\"}[$__rate_interval])) > 0",
"legendFormat": "Скачивание",
"expr": "sum(rate(harbor_device_singbox_tracked_bytes_total{device_id=~\"$device_id\", outbound=\"vpn\", direction=\"download\"}[$__rate_interval])) > 0",
"legendFormat": "VPN · скачивание",
"range": true,
"refId": "A"
},
{
"editorMode": "code",
"expr": "sum(rate(harbor_device_traffic_bytes_total{device_id=~\"$device_id\", direction=\"upload\"}[$__rate_interval])) > 0",
"legendFormat": "Отправка",
"expr": "sum(rate(harbor_device_singbox_tracked_bytes_total{device_id=~\"$device_id\", outbound=\"vpn\", direction=\"upload\"}[$__rate_interval])) > 0",
"legendFormat": "VPN · отправка",
"range": true,
"refId": "B"
},
{
"editorMode": "code",
"expr": "((sum(rate(harbor_device_singbox_tracked_bytes_total{device_id=~\"$device_id\", outbound=\"direct\", direction=\"download\"}[$__rate_interval])) or vector(0)) + (sum(rate(harbor_device_direct_ipv4_packet_bytes_total{device_id=~\"$device_id\", direction=\"download\"}[$__rate_interval])) or vector(0))) > 0",
"legendFormat": "Direct · скачивание",
"range": true,
"refId": "C"
},
{
"editorMode": "code",
"expr": "((sum(rate(harbor_device_singbox_tracked_bytes_total{device_id=~\"$device_id\", outbound=\"direct\", direction=\"upload\"}[$__rate_interval])) or vector(0)) + (sum(rate(harbor_device_direct_ipv4_packet_bytes_total{device_id=~\"$device_id\", direction=\"upload\"}[$__rate_interval])) or vector(0))) > 0",
"legendFormat": "Direct · отправка",
"range": true,
"refId": "D"
},
{
"editorMode": "code",
"expr": "sum(rate(harbor_device_singbox_tracked_bytes_total{device_id=~\"$device_id\", outbound=\"unknown\", direction=\"download\"}[$__rate_interval])) > 0",
"legendFormat": "Не определено · скачивание",
"range": true,
"refId": "E"
},
{
"editorMode": "code",
"expr": "sum(rate(harbor_device_singbox_tracked_bytes_total{device_id=~\"$device_id\", outbound=\"unknown\", direction=\"upload\"}[$__rate_interval])) > 0",
"legendFormat": "Не определено · отправка",
"range": true,
"refId": "F"
}
],
"title": "Скорость трафика",
"title": "Фактический VPN / Direct",
"type": "timeseries"
},
{
@@ -582,7 +715,7 @@
]
},
"gridPos": {
"h": 12,
"h": 16,
"w": 8,
"x": 16,
"y": 5
@@ -648,7 +781,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 17
"y": 21
},
"id": 12,
"panels": [],
@@ -676,7 +809,7 @@
"h": 15,
"w": 9,
"x": 0,
"y": 18
"y": 22
},
"id": 8,
"options": {
@@ -775,7 +908,7 @@
"h": 15,
"w": 15,
"x": 9,
"y": 18
"y": 22
},
"id": 9,
"options": {
@@ -837,7 +970,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 33
"y": 37
},
"id": 13,
"panels": [
@@ -846,7 +979,7 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "Где выбранный трафик вошёл в Harbor: через Gateway или Proxy. Это техническая точка входа, а не выбор VPN / Direct.",
"description": "Как sing-box увидел трафик выбранных устройств: точка входа gateway или proxy и фактически выбранный outbound. Например, компьютер с policy Direct и браузерным Proxy появляется как proxy · vpn.",
"fieldConfig": {
"defaults": {
"color": {
@@ -856,44 +989,13 @@
"noValue": "Нет данных",
"unit": "bytes"
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "gateway"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "blue",
"mode": "fixed"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "proxy"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "purple",
"mode": "fixed"
}
}
]
}
]
"overrides": []
},
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 34
"y": 38
},
"id": 4,
"options": {
@@ -917,14 +1019,14 @@
"targets": [
{
"editorMode": "code",
"expr": "sum by (source) (increase(harbor_device_traffic_bytes_total{device_id=~\"$device_id\"}[$__range])) > 0",
"expr": "sum by (source, outbound) (increase(harbor_device_singbox_tracked_bytes_total{device_id=~\"$device_id\"}[$__range])) > 0",
"instant": true,
"legendFormat": "{{source}}",
"legendFormat": "{{source}} · {{outbound}}",
"range": false,
"refId": "A"
}
],
"title": "Точки входа Gateway / Proxy",
"title": "Вход × выход sing-box",
"type": "bargauge"
},
{
@@ -932,7 +1034,7 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "IPv4-пакеты выбранных устройств, которые Gateway направил напрямую вместо sing-box: policy Direct или работа при остановленном VPN runtime. Это L3 packet bytes с заголовками и retransmit; их нельзя складывать с sing-box tracker bytes.",
"description": "Два непересекающихся Direct-пути выбранных устройств. Через sing-box показаны логические TCP/UDP bytes; Linux мимо sing-box показывает IPv4 L3 packet bytes с заголовками и retransmit. Их сумма в основных панелях является только приблизительной оценкой.",
"fieldConfig": {
"defaults": {
"color": {
@@ -942,13 +1044,44 @@
"noValue": "Нет данных",
"unit": "bytes"
},
"overrides": []
"overrides": [
{
"matcher": {
"id": "byFrameRefID",
"options": "A"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "orange",
"mode": "fixed"
}
}
]
},
{
"matcher": {
"id": "byFrameRefID",
"options": "B"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "purple",
"mode": "fixed"
}
}
]
}
]
},
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 34
"y": 38
},
"id": 16,
"options": {
@@ -972,14 +1105,22 @@
"targets": [
{
"editorMode": "code",
"expr": "sum by (direction) (increase(harbor_device_direct_ipv4_packet_bytes_total{device_id=~\"$device_id\"}[$__range])) > 0",
"expr": "sum(increase(harbor_device_singbox_tracked_bytes_total{device_id=~\"$device_id\", outbound=\"direct\"}[$__range])) > 0",
"instant": true,
"legendFormat": "{{direction}}",
"legendFormat": "Через sing-box",
"range": false,
"refId": "A"
},
{
"editorMode": "code",
"expr": "sum(increase(harbor_device_direct_ipv4_packet_bytes_total{device_id=~\"$device_id\"}[$__range])) > 0",
"instant": true,
"legendFormat": "Linux мимо sing-box",
"range": false,
"refId": "B"
}
],
"title": "Direct IPv4 мимо sing-box",
"title": "Direct раздельно",
"type": "bargauge"
}
],
@@ -1008,7 +1149,7 @@
"uid": "${DS_PROMETHEUS}"
},
"definition": "query_result(label_join(max by (device_id, name, ip) (harbor_device_info), \"display\", \" · \", \"name\", \"ip\"))",
"description": "Выберите все устройства или одно устройство. Фильтр управляет скоростью, общим трафиком, маршрутами, сервисами, доменами и технической детализацией.",
"description": "Выберите все устройства или одно устройство. Фильтр управляет применённым режимом, фактическим VPN/Direct, общим трафиком, сервисами, доменами и технической детализацией.",
"hide": 0,
"includeAll": true,
"label": "Устройства",
@@ -1044,6 +1185,6 @@
"timezone": "browser",
"title": "Harbor Gateway: трафик",
"uid": "harbor-gateway-traffic",
"version": 9,
"version": 10,
"weekStart": "monday"
}