DISTRIBUTED BRAIN METRICS UI
Distributed Brain: Metrics UI and Frontend Integration
This document summarizes recent changes related to displaying real-time metrics in distributed_brain. The purpose is to visualize transmission failure/backpressure indicators during operation and provide a simple front-end display and a source for future graphing.
Modified files (overview)
evospikenet/api_modules/distributed_ws.py:- New/changed endpoints
GET /distributed_brain/metrics— Returns the current counters (send_timeouts,broadcast_drops,persist_drops,connected_clients, etc.) in JSON.POST /distributed_brain/publish_log— Existing log publishing REST API (continued)WebSocket /ws/distributed_brain/logs— Real-time distribution for front end (with authentication)
-
Internal: Implements queues for backpressure, persistent batch flusher, Redis Pub/Sub (optional), etc.
-
frontend/pages/distributed_brain.py: - Added a small text display area for metrics to the log display toolbar (
div#distributed-metrics). - Added
canvas#distributed-metrics-canvasfor drawing metrics to the toolbar (placeholder for drawing graphs in Chart.js etc.). - Poll
fetch('/distributed_brain/metrics')on the client side every 5 seconds, format the received JSON intodiv#distributed-metricsand display it (currently displayed as a numeric value).
API schema (simple)
GET /distributed_brain/metrics→ 200 JSON
{
"send_timeouts": 12,
"broadcast_drops": 3,
"persist_drops": 0,
"connected_clients": 2,
"last_update": "2026-03-09T12:34:56.789Z"
}
Frontend behavior (current)
- Start WS connection after page load (
/ws/distributed_brain/logs). - At the same time, fetch
/distributed_brain/metricsevery 5 seconds and display a simple status on the toolbar. Appears in:distributed-metricson the right side of the toolbar andcanvasfor graphs. - Currently only text is displayed,
canvasis a placeholder for graph display.
Chart.js / About graphing (current status and next steps)
- Change:
canvas#distributed-metrics-canvashas been added. Library installation and initialization scripts such as Chart.js are not applied. Suggested work next: - Load Chart.js, hold a buffer of time series data (e.g. 60 points) and draw a line graph.
- Fetch interval, buffer length, and drawing style can be changed using front settings.
Activation/confirmation steps
- Restart the
apicontainer to load the latest code. example:
docker compose up -d --build api
-
Once the API starts, open the dashboard (
frontend/pages/distributed_brain.py) in your browser and notice that the metrics are updated every 5 seconds in the top right corner of the screen. -
To check the metrics, you can get them directly with curl:
curl -sS http://localhost:8000/distributed_brain/metrics | jq
Environment variables/operation notes
DISTRIBUTED_WS_REDIS(optional): Enables inter-instance broadcasting when given a Redis URL.- Adjust the send timeout and queue size using environment variables such as
DISTRIBUTED_WS_SEND_TIMEOUT(see inevospikenet/api_modules/distributed_ws.py). - If you use Prometheus,
prometheus-clientmust be installed (already included in the Docker image).
Draft release note (short)
- Added real-time metrics display of distributed brain to the front end (added numerical display and graph canvas to the toolbar). The backend provides
GET /distributed_brain/metricsfor metrics. Time series graphs using Chart.js will be enabled in the next phase.
Create the English version docs/DISTRIBUTED_BRAIN_METRICS_UI.en.md if necessary. If you want to apply the chart implementation (Chart.js built-in) now, do you want to continue implementing it?