mirror of
https://github.com/Dvorinka/beszel.git
synced 2026-06-03 21:02:56 +00:00
6.9 KiB
6.9 KiB
Beszel + Uptime Kuma Integration Plan
Architecture Analysis
Beszel (Target Platform)
- Backend: Go with PocketBase framework
- Frontend: React + TypeScript + nanostores
- Database: SQLite via PocketBase collections
- Auth: PocketBase built-in auth
- Real-time: PocketBase subscriptions
- Styling: TailwindCSS + shadcn/ui
Uptime Kuma (Source Features)
- Backend: Node.js with Express
- Frontend: Vue.js
- Database: SQLite with redbean-node ORM
- Monitors: HTTP(s), TCP, Ping, DNS, MQTT, etc.
- Notifications: 90+ providers
- Status Pages: Public-facing status pages
Integration Strategy
Phase 1: Core Data Layer
- Create PocketBase collections for:
monitors- Monitor definitionsmonitor_heartbeats- Check results historymonitor_alerts- Alert configurationsstatus_pages- Public status page configsnotifications- Notification provider settings
Phase 2: Backend Monitoring Engine
- Port monitor check logic from Uptime Kuma to Go
- Implement background scheduler for monitor checks
- Add notification dispatcher
- Create API endpoints for monitor management
Phase 3: Frontend Components
- Dashboard split view: Systems (top) + Monitors (bottom)
- Monitor management UI (CRUD)
- Status page builder
- Notification settings
Phase 4: Testing & Polish
- Unit tests for monitor checks
- Integration tests for notifications
- UI/UX polish following Beszel design
Detailed Implementation
1. Database Schema (PocketBase Collections)
monitors collection
type Monitor struct {
ID string
Name string
Type string // http, tcp, ping, dns, etc.
URL string
Method string // GET, POST, etc.
Interval int // seconds
Timeout int // seconds
Retries int
Headers string // JSON
Body string
Status string // up, down, pending
LastCheck time.Time
UptimeStats map[string]float64
Tags []string
Active bool
UserID string
}
monitor_heartbeats collection
type Heartbeat struct {
ID string
MonitorID string
Status string // up, down
Ping int // response time ms
Msg string // error message or details
Time time.Time
}
2. Monitor Types to Implement
Priority order:
- HTTP/HTTPS - Basic website monitoring
- TCP - Port monitoring
- Ping - ICMP ping
- DNS - DNS resolution check
- Keyword - HTTP with keyword search
- JSON Query - HTTP with JSON path validation
- Docker Container - Container health
3. Notification Providers
Core providers (most used):
- Email (SMTP)
- Discord
- Telegram
- Slack
- Webhook
- Gotify
- Pushover
4. Frontend Layout
┌─────────────────────────────────────────────┐
│ Beszel Header / Navbar │
├─────────────────────────────────────────────┤
│ DEVICE MONITORING (Primary) │
│ ┌───────────────────────────────────────┐ │
│ │ Systems Table / Grid │ │
│ │ [CPU] [Mem] [Disk] [Net] [Status] │ │
│ └───────────────────────────────────────┘ │
├─────────────────────────────────────────────┤
│ WEBSITE & SERVICE MONITORING (Secondary) │
│ ┌───────────────────────────────────────┐ │
│ │ Monitors Table │ │
│ │ [Name] [Type] [URL] [Status] [Uptime] │ │
│ └───────────────────────────────────────┘ │
├─────────────────────────────────────────────┤
│ Footer │
└─────────────────────────────────────────────┘
5. API Endpoints
/api/beszel/monitors GET/POST
/api/beszel/monitors/:id GET/PUT/DELETE
/api/beszel/monitors/:id/check POST (manual check)
/api/beszel/monitors/:id/pause POST
/api/beszel/monitors/:id/resume POST
/api/beszel/monitors/:id/stats GET (uptime stats)
/api/beszel/heartbeats GET (recent heartbeats)
/api/beszel/status-pages GET/POST
/api/beszel/notifications GET/POST/DELETE
/api/beszel/notifications/test POST
File Structure
beszel/
├── internal/
│ ├── hub/
│ │ ├── monitors/ # NEW: Monitor management
│ │ │ ├── monitor.go # Monitor struct and logic
│ │ │ ├── scheduler.go # Check scheduler
│ │ │ └── checks/ # Check implementations
│ │ │ ├── http.go
│ │ │ ├── tcp.go
│ │ │ ├── ping.go
│ │ │ └── dns.go
│ │ ├── notifications/ # NEW: Notification system
│ │ │ ├── dispatcher.go
│ │ │ └── providers/
│ │ │ ├── email.go
│ │ │ ├── discord.go
│ │ │ └── webhook.go
│ │ └── statuspages/ # NEW: Status page system
│ │ └── statuspage.go
│ └── entities/
│ └── monitor/ # NEW: Monitor entities
│ └── monitor.go
├── internal/site/src/
│ ├── components/
│ │ ├── routes/
│ │ │ └── home.tsx # MODIFIED: Split view
│ │ ├── monitors-table/ # NEW
│ │ │ └── monitors-table.tsx
│ │ ├── monitor-detail/ # NEW
│ │ │ └── monitor-detail.tsx
│ │ └── status-pages/ # NEW
│ │ └── status-page-builder.tsx
│ └── lib/
│ └── monitors.ts # NEW: Monitor API client
Testing Strategy
- Unit Tests: Each monitor check type
- Integration Tests: Notification providers
- E2E Tests: Full monitor lifecycle
- Load Tests: Many concurrent monitors
Implementation Order
- Database collections and entities
- HTTP monitor check implementation
- Basic API endpoints
- Frontend monitor table
- Dashboard split view
- TCP/Ping/DNS monitors
- Notification system
- Status pages
- Polish and optimization