update docs

This commit is contained in:
2026-03-16 13:32:49 -03:00
parent 91f95d55a5
commit 0f60556e81
9 changed files with 495 additions and 494 deletions

View File

@@ -231,6 +231,31 @@ machine_metrics_cache[machine_id].update(incoming_metrics)
New metrics merge with existing. The broadcast includes the full merged state.
### Edge Relay - Public Dashboard Without the Cost
The full stack (aggregator, Redis, TimescaleDB) runs on local hardware. But the dashboard needs to be publicly accessible at `sysmonstm.mcrn.ar`. Running the full stack on AWS would be expensive and unnecessary.
The solution is an edge relay (`ctrl/edge/edge.py`). It's a minimal FastAPI app that does one thing: relay WebSocket messages. The gateway forwards metrics to the edge via WebSocket, and the edge broadcasts them to connected browsers:
```python
# Gateway forwards to edge when EDGE_URL is configured
async def forward_to_edge(data: dict):
if edge_ws:
await edge_ws.send(json.dumps(data))
```
The edge receives these and broadcasts to all dashboard viewers:
```python
@app.websocket("/ws")
async def dashboard_ws(websocket: WebSocket):
await websocket.accept()
clients.add(websocket)
# ... broadcasts incoming metrics to all clients
```
This keeps heavy processing (gRPC, storage, event evaluation) on local hardware and puts only a lightweight relay in the cloud. The AWS instance has no databases, no gRPC, no storage — just WebSocket in, WebSocket out.
## Phase 3: Alerts - Adding Intelligence
The alerts service subscribes to metric events and evaluates them against rules.
@@ -402,7 +427,8 @@ Set `COLLECTOR_AGGREGATOR_URL=192.168.1.100:50051` and it overrides the default.
| Redis events | `shared/events/redis_pubsub.py` | Redis Pub/Sub implementation |
| Configuration | `shared/config.py` | Pydantic settings for all services |
| DB initialization | `scripts/init-db.sql` | TimescaleDB schema, hypertables |
| Docker setup | `docker-compose.yml` | Full stack orchestration |
| Edge relay | `ctrl/edge/edge.py` | WebSocket relay for AWS dashboard |
| Docker setup | `ctrl/dev/docker-compose.yml` | Full stack orchestration |
## Running It