Production-grade, distributed server monitoring and telemetry infrastructure with lightweight Go agents, real-time metrics, interactive web terminals, Loki log streaming, and Next.js frontend console.
- Overview
- System Architecture
- Key Features
- Tech Stack
- Getting Started
- Running the Platform
- Project Structure
- Available Scripts
- Testing
- Deployment & Agent Installation
- Configuration Reference
- Contributing
- License
SentryNode is a complete, full-stack infrastructure observability platform designed for DevOps and Site Reliability Engineering teams managing multi-server fleets. It bridges the gap between low-level kernel telemetry and human-friendly web operations by combining:
- An ultra-fast, single-binary Go telemetry daemon running across Linux, macOS, and Windows nodes.
- A central orchestration backend powered by Node.js, Express, TypeScript, and Drizzle ORM.
- A Next.js web application featuring interactive dashboards, live LogQL stream viewers, real-time resource gauges, cron task runners, and browser-embedded xterm.js terminals.
flowchart TD
subgraph Managed Nodes ["Managed Nodes / Remote Servers"]
Agent1["SentryNode Agent<br/>(Linux/WSL)"]
Agent2["SentryNode Agent<br/>(Windows/Darwin)"]
end
subgraph Observability ["Observability Infrastructure"]
Prometheus["Prometheus (9090)<br/>• Pulls :8081 /metrics<br/>• Evaluates alert_rules.yml"]
Loki["Grafana Loki (3100)<br/>• Ingests log streams"]
end
subgraph Orchestration ["SentryNode Backend (Port 8080)"]
API["Express REST API (/api/v1)"]
WSRelay["WebSocket Terminal & Stream Relay (/ws)"]
AlertSync["Prometheus Alert Sync Loop"]
DB[("PostgreSQL / SQLite<br/>(Drizzle ORM)")]
end
subgraph UserInterface ["SentryNode Web Console (Port 3000)"]
Dashboard["Fleet Overview & Metrics"]
TerminalUI["xterm.js Remote Terminal"]
LogViewer["Live Loki Log Explorer"]
TaskRunner["Remote Cron Task Dispatcher"]
end
Agent1 -- "Heartbeat & Registration" --> API
Agent1 -- "Push Logs" --> API
Agent1 -- "Interactive PTY Session" <--> WSRelay
Agent2 -- "Push Logs" --> API
API -- "Proxy Push (/api/v1/logs/push)" --> Loki
Prometheus -- "HTTP Service Discovery" --> API
Prometheus -- "Scrape Telemetry" --> Agent1
AlertSync -- "Poll Active Alerts" --> Prometheus
AlertSync --> DB
API --> DB
UserInterface <--> API
TerminalUI <--> WSRelay
- 📊 Real-Time Host Telemetry: Live collection of CPU (per-core and aggregated), Memory, Disk I/O, Network throughput, 1/5/15-minute Load averages, and OS/hardware metadata.
- 🐳 Docker Container Inspection: Live container discovery, CPU/memory stats, network I/O, restart counts, and container lifecycle events.
- 🪵 Log Streaming & Loki Pipeline: Multi-file watcher, regex parser, batch accumulator, and automatic forwarding to Grafana Loki.
- 💻 Browser-Based Remote Web Terminal: Interactive bidirectional shell terminal (xterm.js + PTY) over secure WebSockets directly into remote servers without opening SSH ports.
- ⏰ Distributed Task Scheduling: Web-triggered and cron-scheduled script execution on remote hosts with command whitelisting and real-time execution logs.
- 🚨 Automated Alerting & Notifications: Prometheus alert rule evaluation (
alert_rules.yml) with automated status synchronization and persistent notification history. - ⚡ Redis Telemetry Cache & Rate Limiting: High-performance agent heartbeat/telemetry caching with zero-latency responses and distributed cluster-wide rate limiting (
rate-limit-redis). - 🔐 Zero-Trust Agent Enrollment: Secure token-based registration flow with temporary enrollment tokens and permanent cryptographic credential generation.
| Component | Technologies |
|---|---|
| Go Agent | Go 1.25, gopsutil, gorilla/websocket, robfig/cron/v3, creack/pty, prometheus/client_golang |
| Backend API | Node.js, Express, TypeScript, Drizzle ORM, ioredis, rate-limit-redis, Better-Auth, PostgreSQL (pg), ws, Pino, Swagger (swagger-ui-express) |
| Frontend UI | Next.js 16 (App Router), React 19, Tailwind CSS v4, Radix UI / Shadcn, TanStack Query v5, Recharts, @xterm/xterm, Lucide Icons |
| Observability & Cache | Prometheus v2.50, Grafana Loki 3.0, Redis 7.2 |
| Tooling & CI | Vitest, ESLint, Prettier, Husky, TypeScript, pnpm |
- Go:
1.22+(Go 1.24+ recommended) - Node.js:
20.xor22.x LTS - Package Manager:
pnpm 9+ - Docker & Docker Compose: For running Prometheus and Loki services
-
Clone the repository:
git clone https://github.com/mahesh2-lab/Sentrynode.git cd Sentrynode -
Install Backend dependencies:
cd backend pnpm install cd ..
-
Install Frontend dependencies:
cd frontend pnpm install cd ..
Copy the template from backend/.env.example:
cp backend/.env.example backend/.envKey environment variables:
# Server Configuration
NODE_ENV=development
PORT=8080
API_PREFIX=/api/v1
# Database Configuration (PostgreSQL or SQLite)
DATABASE_URL=postgres://postgres:postgres@localhost:5432/monitoring_db
# Security & Secrets
JWT_SECRET=your-secret-jwt-key-min-32-chars-long!
BETTER_AUTH_SECRET=your-better-auth-secret-min-32-chars!
BETTER_AUTH_URL=http://localhost:8080
FRONTEND_URL=http://localhost:3000
CORS_ORIGIN=http://localhost:3000,http://localhost:5173
# Prometheus Target Discovery Host
PROMETHEUS_AGENT_HOST=host.docker.internalNEXT_PUBLIC_AUTH_URL=http://localhost:8080Launch Prometheus and Loki in the background using Docker Compose:
cd configs
docker compose up -d
cd ..- Prometheus UI:
http://localhost:9090 - Loki Push Endpoint:
http://localhost:3100
Run database migrations and start the development server:
cd backend
pnpm db:migrate
pnpm devThe Backend API will be available at http://localhost:8080.
- Swagger Documentation:
http://localhost:8080/docs - Health Check:
http://localhost:8080/health - Prometheus Targets:
http://localhost:8080/api/v1/prometheus/targets
In a new terminal, start the Next.js frontend:
cd frontend
pnpm devOpen http://localhost:3000 in your browser.
cd agent
go run ./cmd/agentGenerate an enrollment token in the web console under /setup or /settings, then start the agent:
cd agent
go run ./cmd/agent --auth-token "YOUR_ENROLLMENT_TOKEN".
├── agent/ # Go Telemetry Monitoring Agent
│ ├── cmd/agent/main.go # Agent daemon entrypoint
│ ├── internal/
│ │ ├── collector/ # CPU, Memory, Disk, Network, Host, Docker metrics
│ │ ├── config/ # YAML configuration & JSON credentials loader
│ │ ├── events/ # System & container event telemetry
│ │ ├── executor/ # Cron task scheduler & command executor
│ │ ├── exporter/ # Standalone Prometheus HTTP exporter (:8081)
│ │ ├── lock/ # Cross-platform single instance file lock
│ │ ├── logs/ # File watcher, parser & Loki log shipper
│ │ ├── terminal/ # Interactive PTY web terminal session manager
│ │ └── transport/ # HTTP client, WebSocket client, retry policies
│ ├── go.mod # Go module definition (sentrynode-agent)
│ └── install.sh # Linux shell installation script
│
├── backend/ # Node.js / Express / TypeScript Backend
│ ├── src/
│ │ ├── app.ts # Express application factory & middleware setup
│ │ ├── index.ts # HTTP & WebSocket server bootstrap
│ │ ├── auth.ts # Better-Auth authentication configuration
│ │ ├── config/ # Environment, JWT, DB, and Swagger configs
│ │ ├── db/ # Drizzle ORM schemas, migrations, relations
│ │ ├── middleware/ # Hybrid auth, RBAC, rate-limiting, error handlers
│ │ └── modules/ # Domain modules (agents, alerts, logs, metrics, etc.)
│ ├── tests/ # Vitest unit & integration test suites
│ └── package.json # Backend package manifest (sentrynode-backend)
│
├── frontend/ # Next.js 16 Web Dashboard & Console
│ ├── app/ # App Router routes (servers, metrics, logs, terminal, etc.)
│ ├── src/
│ │ ├── components/ # Reusable UI cards, tables, gauges, xterm terminal
│ │ ├── hooks/ # Data-fetching hooks (React Query, Prometheus, Loki)
│ │ └── lib/ # Utility functions & auth clients
│ └── package.json # Frontend package manifest (sentrynode-frontend)
│
├── configs/ # Infrastructure & Deployment Assets
│ ├── docker-compose.yml # Prometheus & Loki stack
│ ├── prometheus.yml # Prometheus scrape configuration
│ ├── alert_rules.yml # Prometheus alerting rules
│ ├── config.yaml # Default agent configuration template
│ ├── Dockerfile.agent # Multi-stage Dockerfile for Go Agent
│ ├── Dockerfile.backend # Dockerfile for Backend API
│ ├── build.ps1 / build.sh # Multi-arch agent cross-compilation scripts
│ └── deploy-wsl.ps1 # Local WSL deployment helper
│
└── BACKEND_DOCUMENTATION.md # Detailed architectural and API documentation
| Command | Description |
|---|---|
pnpm dev |
Start backend in development mode with live reload (tsx watch) |
pnpm build |
Bundle backend for production with tsup |
pnpm start |
Run compiled production build from dist/index.js |
pnpm db:migrate |
Apply pending database schema migrations |
pnpm db:generate |
Generate Drizzle migrations from schema definitions |
pnpm db:studio |
Open Drizzle Studio visual database inspector |
pnpm test |
Run backend unit and integration tests with vitest |
pnpm lint |
Lint codebase with ESLint |
pnpm typecheck |
Run TypeScript type checking without emitting files |
| Command | Description |
|---|---|
pnpm dev |
Start Next.js development server on http://localhost:3000 |
pnpm build |
Create optimized production Next.js build |
pnpm start |
Start production Next.js server |
pnpm test |
Run frontend component and hook tests with vitest |
pnpm typecheck |
Validate TypeScript types across frontend |
pnpm lint |
Run Next.js ESLint verification |
| Command | Description |
|---|---|
go run ./cmd/agent |
Run agent directly from source |
go test ./... |
Run unit tests across all internal packages |
go build -o ../bin/sentrynode ./cmd/agent |
Build native executable |
cd backend
pnpm testcd frontend
pnpm testcd agent
go test -v ./...The backend serves an automated installer script that configures the agent binary, directory structure, environment variables, and systemd daemon:
curl -sSL http://<YOUR_BACKEND_HOST>:8080/install.sh | sudo bash -s -- --auth-token "<YOUR_ENROLLMENT_TOKEN>"Start and manage the service on the target machine:
# Check status
sudo systemctl status sentrynode
# View live logs
sudo journalctl -u sentrynode -fCompile lightweight, statically linked binaries for all target architectures using the provided build scripts:
Linux / macOS:
chmod +x configs/build.sh
./configs/build.shWindows (PowerShell):
.\configs\build.ps1Generated outputs in bin/:
agent-linux-amd64agent-linux-arm64agent-windows-amd64.exeagent-darwin-amd64agent-darwin-arm64
To run the full stack with Docker:
# Build & run services
docker compose -f configs/docker-compose.yml up -d| Variable | Default | Description |
|---|---|---|
PORT |
8080 |
HTTP and WebSocket listening port |
NODE_ENV |
development |
Environment mode (development, production, test) |
DATABASE_URL |
— | Connection string for PostgreSQL or SQLite |
JWT_SECRET |
— | Cryptographic secret for signing access tokens |
BETTER_AUTH_SECRET |
— | Cryptographic secret for Better-Auth session tokens |
CORS_ORIGIN |
http://localhost:3000 |
Allowed origins for cross-origin requests |
PROMETHEUS_AGENT_HOST |
host.docker.internal |
Hostname used by Prometheus to reach node exporters |
REDIS_URL |
redis://localhost:6379 |
Connection string for Redis cache & rate limiter |
ENABLE_REDIS |
true |
Enable or disable Redis caching and distributed rate limiting |
- Fork the repository on GitHub.
- Create a branch for your feature or bugfix (
git checkout -b feat/my-new-feature). - Commit changes following the Conventional Commits convention (
git commit -m "feat(agent): add gpu telemetry"). - Push to your fork (
git push origin feat/my-new-feature). - Open a Pull Request with a description of your changes and test coverage.
This project is licensed under the MIT License.