Skip to content

从0到1实现 AI 模型实时监控系统 (Watch-System)#1

Merged
LLibra1 merged 3 commits intomainfrom
copilot/add-website-monitoring-system
Apr 23, 2026
Merged

从0到1实现 AI 模型实时监控系统 (Watch-System)#1
LLibra1 merged 3 commits intomainfrom
copilot/add-website-monitoring-system

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 23, 2026

从空仓库完整实现一套实时 Web 监控平台,可视化追踪 8 个主流开源 AI 模型(LLaMA2、Mistral、CodeLlama、Phi-2、Gemma、Qwen、DeepSeek)的调用状态与性能指标。

AI 模型监控系统仪表板

后端 (backend/)

  • Express + Socket.IO 服务:REST API + WebSocket 双通道;生产模式同时 serve 前端静态文件
  • SQLite 持久化better-sqlite3):requests / models 双表,支持 P95 延迟查询
  • 模型模拟器:8 个模型各有独立响应特性(延迟范围、Token 量、错误率 2–8%),间隔 MIN_REQUEST_DELAY_MSMAX_REQUEST_DELAY_MS 随机触发
  • 告警管理器:每 10s 检测错误率 >10%、平均延迟 >3s、流量突刺,自动创建/解除告警并通过 Socket.IO 推送
  • REST APIGET /api/models · /api/metrics[/:model] · /api/history/:model · /api/alerts · POST /api/simulate
  • Socket.IO 事件request_completed(即时)、metrics_update(每 5s 全量)、alert_created/resolved

前端 (frontend/)

  • 单页深色仪表板(Grafana 风格):请求量趋势折线图、请求分布饼图、响应时间横向柱状图、8 个模型卡片(含 Sparkline + 健康状态指示)、滚动请求日志(最近 20 条)、告警面板
  • BACKEND URL 动态推断(window.location),不再硬编码 localhost:3001,适配任意部署环境
  • frontend/lib/ 本地捆绑 Chart.js 和 Socket.IO 客户端,消除 CDN 依赖

安全

CORS 改为环境感知配置:生产模式直接禁用(同源),开发模式仅允许 localhost 显式来源,移除通配符 *

const corsOptions = {
  origin: isProduction ? false : DEV_ORIGINS, // DEV_ORIGINS = localhost:3000/3001 or FRONTEND_ORIGIN env
  methods: ['GET', 'POST'],
};

文档

  • README.md:架构 ASCII 图、功能表、API 参考、Socket.IO 事件表、模型特性对比、启动方式
  • docs/project-plan.md:项目背景、系统设计、数据流、开发里程碑
  • docker-compose.yml + backend/Dockerfile:一键容器化部署

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.jsdelivr.net
    • Triggering command: /usr/bin/curl curl -sL REDACTED -o /home/REDACTED/work/Watch-System/Watch-System/frontend/lib/chart.min.js uild --release --global rgo/bin/git committer.email (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

从0-1实现项目:实现一个网页监控系统,实时监控一些开源模型的使用。
第一:根据项目描述总结项目markdown文件,其中要对项目进行合理的拆解。
第二:实现markdown文件中的项目
第三:项目每进行一段时间检查之前的实现是否合理,是否能够完成任务,以及是否能够实现任务目标。

Copilot AI and others added 2 commits April 23, 2026 07:33
- Backend: Node.js + Express + Socket.IO + better-sqlite3
  - server.js: HTTP/WebSocket server, real-time metrics broadcast
  - database.js: SQLite schema, 8 model seeds, P95 latency queries
  - routes/api.js: REST API for models, metrics, history, alerts
  - services/simulator.js: Per-model realistic request simulation
  - services/alertManager.js: Error rate / latency / spike alerts

- Frontend: Single-page Grafana-style dark dashboard
  - Chart.js line/doughnut/bar charts with real-time updates
  - 8 model cards with sparklines and health indicators
  - Live request log table and alert panel
  - Socket.IO WebSocket real-time data binding

- Infrastructure: Dockerfile + docker-compose.yml
- Docs: Chinese README and project-plan.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: LLibra1 <195303685+LLibra1@users.noreply.github.com>
@LLibra1 LLibra1 marked this pull request as ready for review April 23, 2026 08:06
@LLibra1 LLibra1 merged commit 7dd32d7 into main Apr 23, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants