Files
flvx/plans/040-service-monitor-configurable-limits-and-ui-hints.md
sagitchu 9de240f034 feat(monitoring): add node/tunnel metrics, service monitors, and health checks
- 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
2026-03-17 14:59:09 +08:00

1.8 KiB

040 - Service Monitor Limits Config + UI Hints

Goal

Make service monitor interval/timeout constraints configurable (instead of hard-coded clamps) and make the UI clearly communicate the effective limits.

Current Pain

  • Backend clamps intervalSec and timeoutSec with hard-coded constants.
  • Checker scan cadence is also hard-coded, so users can set values that will never be honored.
  • Frontend form does not explain allowed ranges or why values may change.

Approach

  • Add frontend-configurable limits stored in vite_config (with safe defaults matching current behavior).
  • Backend always normalizes using the configured limits.
  • Expose the current limits via a monitoring endpoint so the UI can render accurate hints.
  • Frontend shows min/max and validates before submit.
  • Admin can edit the limits on /config.

Config Keys (vite_config)

  • service_monitor_checker_scan_interval_sec (default: 30)
  • service_monitor_min_interval_sec (default: 30; auto-raised to at least scan interval)
  • service_monitor_default_interval_sec (default: 60)
  • service_monitor_min_timeout_sec (default: 1)
  • service_monitor_default_timeout_sec (default: 5)
  • service_monitor_max_timeout_sec (default: 60)

Checklist

Backend:

  • Introduce shared ServiceMonitorLimits config loader.
  • Use limits for create/update normalization.
  • Use limits in checker (scan interval + timeout clamp).
  • Add GET /api/v1/monitor/services/limits to return current limits.

Frontend:

  • Fetch limits once and render input descriptions.
  • Validate interval/timeout client-side and show inline errors.
  • Add /config items to edit the vite_config keys.

Verification:

  • cd go-backend && go test ./... -count=1
  • cd vite-frontend && npm run lint && npm run build