mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-28 07:36:38 +08:00
9de240f034
- Add NodeMetric/TunnelMetric/ServiceMonitor models and repository methods - Implement metrics ingestion service with per-minute bucket aggregation - Add health checker for node connectivity monitoring - Wire node metrics from WebSocket SystemInfo messages - Add tunnel metrics ingestion from flow upload endpoint - Create monitoring REST API endpoints for nodes, tunnels, services - Implement service monitor CRUD and execution (TCP/ICMP checks) - Add MonitorPermission for non-admin access control - Create frontend monitor page with node/tunnel/service views - Add tunnel metrics ingestion from agent flow reports - Include schema migration for tunnel_metric unique index - Fix tunnel entry port conflict validation to use transaction Entire-Checkpoint: 030821a7c8e3
1.6 KiB
1.6 KiB
039 - Monitoring: Tunnel Metrics Ingestion
Context
The /monitor UI includes tunnel metric charts backed by:
GET /api/v1/monitor/tunnels(list)GET /api/v1/monitor/tunnels/:id/metrics(timeseries)
The backend has the tunnel_metric table + query endpoints, but there is no production code path that writes tunnel metrics. As a result, tunnel charts are typically empty.
Goal
Persist tunnel traffic timeseries based on agent flow uploads (POST /flow/upload).
Scope
- Write
tunnel_metricrows from flow uploads. - Keep write volume bounded (aggregate per minute).
- Provide contract coverage that a flow upload creates tunnel metrics.
Non-goals
- Populate connections/errors/latency for tunnel metrics (remain 0 for now).
- A full aggregation pipeline across multiple nodes per tunnel at query time.
UI note:
- The tunnel chart only exposes the Traffic view for now; other tabs are hidden.
Design
- Agent reports per-service traffic deltas via
/flow/uploadwith items{n,u,d}. - Backend derives
forward_idfrom service name (<forwardID>_<userID>_<userTunnelID>[...suffix]). - Map
forward_id -> tunnel_idin batch. - Aggregate per
(node_id, tunnel_id, minute_bucket)and upsert intotunnel_metricusing an UPDATE-then-INSERT fallback.
Checklist
- Add repository helper: map forward IDs to tunnel IDs.
- Add repository helper: upsert per-minute tunnel metric buckets.
- Extend
/flow/uploadhandler to record tunnel metrics from incoming items. - Add contract test verifying flow upload produces tunnel metrics.
- Run backend tests.
Test Plan
cd go-backend && go test ./... -count=1