Skip to content

Commit 2aa1c34

Browse files
Daydreamer-Lisamchu-zsl
authored andcommitted
feat(agentsight): add AgentSight Dashboard web UI (#74)
Close #74 Introduce a React-based web Dashboard to provide an interactive visualization interface for AgentSight: - Add dashboard/ frontend source under src/agentsight/dashboard/ with webpack embed output path set to ../frontend-dist - Add Makefile targets build-frontend and build-all for one-step frontend + Rust builds - Update README / README_CN with agentsight serve command usage, two scenarios (live tracing vs. historical data browsing), and remote server access guide Signed-off-by: liyuqing <liyuqing@alibaba-inc.com>
1 parent bd50203 commit 2aa1c34

19 files changed

Lines changed: 11088 additions & 0 deletions

src/agentsight/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
build: ## Build agentsight binary
77
cargo build --release
88

9+
.PHONY: build-frontend
10+
build-frontend: ## Build and embed frontend into frontend-dist/
11+
cd dashboard && npm install && npm run build:embed
12+
13+
.PHONY: build-all
14+
build-all: build-frontend build ## Build frontend then Rust binary (with embedded UI)
15+
916
# =============================================================================
1017
# INSTALL
1118
# =============================================================================

src/agentsight/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,21 @@ agentsight audit --pid 12345 --type llm
117117
agentsight audit --summary
118118
```
119119

120+
### `agentsight serve`
121+
122+
Start the HTTP API server and serve the embedded Dashboard UI.
123+
124+
```bash
125+
# Start with default settings (binds to 127.0.0.1:7396)
126+
agentsight serve
127+
128+
# Bind to all interfaces on a custom port
129+
agentsight serve --host 0.0.0.0 --port 8080
130+
131+
# Point to a specific database file
132+
agentsight serve --db /path/to/genai_events.db
133+
```
134+
120135
### `agentsight discover`
121136

122137
Discover AI agents running on the system.
@@ -132,6 +147,68 @@ agentsight discover --list
132147
agentsight discover --verbose
133148
```
134149

150+
## Dashboard
151+
152+
The Dashboard is a React-based web UI for visualizing conversation history, trace details, and token statistics. It is embedded into the `agentsight serve` binary at compile time.
153+
154+
### Build the Dashboard
155+
156+
```bash
157+
cd src/agentsight
158+
159+
# Build frontend and embed into frontend-dist/ (required before cargo build)
160+
make build-frontend
161+
162+
# Then build the Rust binary with the embedded UI
163+
make build
164+
165+
# Or do both in one step
166+
make build-all
167+
```
168+
169+
### Scenario 1 — Collect data and view the Dashboard simultaneously
170+
171+
Run the tracer and the API server in two separate terminals:
172+
173+
```bash
174+
# Terminal 1: start eBPF tracing (writes to SQLite)
175+
sudo agentsight trace
176+
177+
# Terminal 2: start the API server (reads from the same SQLite)
178+
agentsight serve
179+
```
180+
181+
Open `http://127.0.0.1:7396` in your browser. The Dashboard auto-refreshes as new data arrives.
182+
183+
> **Running on a remote server?** Bind to all interfaces and access via the server's public IP:
184+
> ```bash
185+
> agentsight serve --host 0.0.0.0 --port 7396
186+
> ```
187+
> Then open `http://<server-public-ip>:7396` in your local browser.
188+
> Make sure port 7396 is allowed in the server's firewall / security group rules.
189+
190+
### Scenario 2 — Browse historical data only
191+
192+
No tracing needed. Just start the server pointing at an existing database:
193+
194+
```bash
195+
agentsight serve --db /path/to/genai_events.db
196+
```
197+
198+
Open `http://127.0.0.1:7396` to explore recorded conversations and traces.
199+
200+
### Dashboard Development
201+
202+
To iterate on the frontend without rebuilding the Rust binary:
203+
204+
```bash
205+
cd src/agentsight/dashboard
206+
npm install
207+
npm run dev # starts webpack-dev-server on http://localhost:3004
208+
```
209+
210+
When finished, run `make build-frontend && cargo build --release` to embed the updated UI.
211+
135212
## Quick Start
136213
137214
### Prerequisites

src/agentsight/README_CN.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,21 @@ agentsight audit --pid 12345 --type llm
117117
agentsight audit --summary
118118
```
119119

120+
### `agentsight serve`
121+
122+
启动 HTTP API 服务器,同时提供嵌入式 Dashboard UI。
123+
124+
```bash
125+
# 使用默认配置启动(绑定到 127.0.0.1:7396)
126+
agentsight serve
127+
128+
# 绑定到所有网络接口并指定端口
129+
agentsight serve --host 0.0.0.0 --port 8080
130+
131+
# 指定数据库文件路径
132+
agentsight serve --db /path/to/genai_events.db
133+
```
134+
120135
### `agentsight discover`
121136

122137
发现系统上运行的 AI Agent。
@@ -132,6 +147,57 @@ agentsight discover --list
132147
agentsight discover --verbose
133148
```
134149

150+
## Dashboard
151+
152+
Dashboard 是基于 React 的 Web 可视化界面,用于查看对话历史、Trace 详情和 Token 统计数据。它在编译时嵌入到 `agentsight serve` 二进制文件中。
153+
154+
### 构建 Dashboard
155+
156+
```bash
157+
cd src/agentsight
158+
159+
# 构建前端并输出到 frontend-dist/(cargo build 前必须先执行)
160+
make build-frontend
161+
162+
# 再构建包含嵌入 UI 的 Rust 二进制
163+
make build
164+
165+
# 或一步完成
166+
make build-all
167+
```
168+
169+
### 场景一 — 同时采集数据并查看 Dashboard
170+
171+
在两个终端中分别运行追踪器和 API 服务器:
172+
173+
```bash
174+
# 终端 1:启动 eBPF 追踪(写入 SQLite)
175+
sudo agentsight trace
176+
177+
# 终端 2:启动 API 服务器(读取同一 SQLite 文件)
178+
agentsight serve
179+
```
180+
181+
在浏览器中打开 `http://127.0.0.1:7396`,Dashboard 会随新数据自动刷新。
182+
183+
> **在远程服务器上运行?** 绑定到所有网络接口,通过服务器公网 IP 访问:
184+
> ```bash
185+
> agentsight serve --host 0.0.0.0 --port 7396
186+
> ```
187+
> 然后在本地浏览器中打开 `http://<服务器公网IP>:7396`
188+
> 请确保服务器防火墙 / 安全组已放行 7396 端口。
189+
190+
### 场景二 — 仅查看历史数据
191+
192+
无需启动追踪,直接指向已有数据库启动服务器:
193+
194+
```bash
195+
agentsight serve --db /path/to/genai_events.db
196+
```
197+
198+
打开 `http://127.0.0.1:7396` 即可浏览已记录的对话和 Trace。
199+
200+
135201
## 快速开始
136202

137203
### 环境要求
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 依赖文件
2+
node_modules/
3+
4+
# 构建输出
5+
dist/
6+
build/
7+
8+
# 环境变量文件
9+
.env
10+
.env.local
11+
12+
# 日志文件
13+
*.log
14+
15+
# 编辑器配置
16+
.vscode/
17+
18+
# cursor 相关
19+
.cursorrules
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="zh-CN">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Agent可观测</title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)