Hermes Agent: 仪表盘
最后更新:2026-08-31
仪表盘是 Hermes Agent 的控制面板——Token 消耗、成本趋势、工具使用频率、记忆增长,一切数据一目了然。
💡 提示:仪表盘提供 CLI 文本版和 Web 图形版两种界面。定期查看仪表盘可以帮助优化成本和发现异常。
📋 前置知识:第4课 模型配置、第10课 定时任务
1. 你将学到
| 编号 | 内容 |
|---|---|
| ❶ | 仪表盘功能概览 |
| ❷ | 使用统计与成本分析 |
| ❸ | 性能监控 |
| ❹ | 健康检查与告警 |
| ❺ | 自定义仪表盘 |
2. 故事
(1) 痛点:不知道 AI 花了多少钱
Bob 用了一个月 Hermes,不知道消耗了多少 Token、花了多少钱。到了月底收到 API 账单才大吃一惊。
(2) 解法:仪表盘实时监控
Alice 每天看仪表盘:
BASH
hermes dashboard
# ┌─ Hermes Dashboard ─────────────────────┐
# │ │
# │ 💰 本月成本: $14.32 / 预算 $50 │
# │ 📊 Token 消耗: 3.2M / 10M │
# │ ⏱️ 平均响应: 2.3s │
# │ 🔧 工具调用: 847 次 │
# │ 📝 记忆条目: 156 条 │
# │ │
# │ 📈 成本趋势 (7天) │
# │ 3/9 ■■■■■■■□□□ $2.10 │
# │ 3/10 ■■■■■■□□□□ $1.80 │
# │ 3/11 ■■■■■■■■■□ $2.50 │
# │ 3/12 ■■■■□□□□□□ $1.20 │
# │ 3/13 ■■■■■■■■□□ $2.30 │
# │ 3/14 ■■■■■■■■■■ $2.80 │
# │ 3/15 ■■■■■■□□□□ $1.62 (今日至今) │
# └─────────────────────────────────────────┘
3. 仪表盘功能概览
(1) 核心指标
| 指标 | 说明 | 单位 |
|---|---|---|
| 月度成本 | API 调用总费用 | USD |
| Token 消耗 | 输入+输出 Token | 百万 |
| 平均响应时间 | LLM 推理延迟 | 秒 |
| 工具调用次数 | 各工具使用频率 | 次 |
| 记忆条目 | 长期记忆数量 | 条 |
| 技能使用 | 各技能调用次数 | 次 |
(2) 访问方式
BASH
# CLI 文本版
hermes dashboard
# Web 图形版
hermes dashboard --web --port 3000
# 浏览器打开 http://localhost:3000
# 单项指标查询
hermes stats cost
hermes stats tokens
hermes stats tools
4. 使用统计与成本分析
(1) 成本报告
BASH
hermes cost report --month
# 输出:
# ┌──────────────┬──────────┬───────────┬───────────┬─────────┐
# │ Model │ Requests │ Tokens In │ Tokens Out│ Cost │
# ├──────────────┼──────────┼───────────┼───────────┼─────────┤
# │ gpt-4o-mini │ 1,200 │ 2.4M │ 0.8M │ $2.16 │
# │ gpt-4o │ 80 │ 0.8M │ 0.4M │ $6.00 │
# │ claude-3.5 │ 40 │ 0.6M │ 0.3M │ $5.70 │
# │ llama3.2 │ 500 │ 1.0M │ 0.5M │ $0.00 │
# ├──────────────┼──────────┼───────────┼───────────┼─────────┤
# │ Total │ 1,820 │ 4.8M │ 2.0M │ $13.86 │
# └──────────────┴──────────┴───────────┴───────────┴─────────┘
(2) 按任务类型分析
BASH
hermes cost report --by-task
# 输出:
# ┌──────────────┬──────────┬─────────┬────────────┐
# │ Task Type │ Requests │ Cost │ % of Total │
# ├──────────────┼──────────┼─────────┼────────────┤
# │ code_review │ 120 │ $4.50 │ 32% │
# │ web_search │ 340 │ $2.80 │ 20% │
# │ chat │ 800 │ $3.20 │ 23% │
# │ translation │ 200 │ $1.86 │ 13% │
# │ cron_tasks │ 360 │ $1.50 │ 11% │
# └──────────────┴──────────┴─────────┴────────────┘
(3) 成本预算
YAML
# 配置月度预算
dashboard:
budget:
monthly_limit: 50 # 月预算50 USD
warning_threshold: 0.8 # 80%时警告
daily_limit: 5 # 日预算5 USD
alerts:
- type: "cost_threshold"
threshold: 40 # 40 USD时告警
notify: "telegram"
- type: "daily_exceed"
notify: "telegram"
5. 性能监控
(1) 响应时间
BASH
hermes stats latency
# 输出:
# ┌──────────────┬─────────┬─────────┬─────────┐
# │ Model │ Avg (s) │ P50 (s) │ P99 (s) │
# ├──────────────┼─────────┼─────────┼─────────┤
# │ gpt-4o-mini │ 1.2 │ 1.0 │ 3.5 │
# │ gpt-4o │ 2.8 │ 2.5 │ 6.2 │
# │ claude-3.5 │ 3.1 │ 2.8 │ 7.0 │
# │ llama3.2 │ 4.5 │ 4.0 │ 12.0 │
# └──────────────┴─────────┴─────────┴─────────┘
(2) 工具使用统计
BASH
hermes stats tools
# 输出:
# ┌──────────────┬──────────┬─────────┬──────────┐
# │ Tool │ Calls │ Avg Time│ Success │
# ├──────────────┼──────────┼─────────┼──────────┤
# │ fs_read │ 312 │ 0.1s │ 99.7% │
# │ code_python │ 145 │ 3.2s │ 97.2% │
# │ web_search │ 89 │ 2.1s │ 98.9% │
# │ fs_write │ 67 │ 0.2s │ 100% │
# │ vision │ 23 │ 5.8s │ 95.7% │
# └──────────────┴──────────┴─────────┴──────────┘
6. 健康检查与告警
(1) 系统健康
BASH
hermes health
# 输出:
# ✅ Agent Core: Running
# ✅ Memory System: OK (156 entries, 12 MB)
# ✅ Skills Engine: OK (8 active)
# ✅ Tool Registry: OK (72 tools)
# ⚠️ Ollama Connection: Slow (2.5s response)
# ✅ OpenAI API: OK (latency 1.2s)
# ✅ Disk Space: OK (85% free)
# ⚠️ Memory Usage: 78% (consider cleanup)
(2) 告警配置
YAML
dashboard:
alerts:
- type: "api_error_rate"
threshold: 0.05 # 5% 错误率
notify: "telegram"
- type: "latency_spike"
threshold: 10 # 超过10秒
notify: "email"
- type: "disk_space"
threshold: 0.9 # 90% 使用
notify: "telegram"
- type: "memory_usage"
threshold: 0.85 # 85% 使用
notify: "telegram"
7. 自定义仪表盘
(1) 自定义指标
YAML
dashboard:
custom_metrics:
- name: "code_reviews_today"
query: "SELECT COUNT(*) FROM tool_calls WHERE tool='code_review' AND date=today"
display: "number"
- name: "cost_savings_vs_gpt4"
calculation: "total_cost * 0.6" # 假设全用GPT-4会贵60%
display: "trend"
(2) Web 仪表盘定制
BASH
# 启动 Web 仪表盘
hermes dashboard --web --port 3000
# 自定义面板布局
cat > ~/.hermes/dashboard-layout.yaml << EOF
panels:
- type: "cost_chart"
position: "top-left"
time_range: "30d"
- type: "tool_usage"
position: "top-right"
top_n: 10
- type: "model_distribution"
position: "bottom-left"
- type: "health_status"
position: "bottom-right"
EOF
❓ 常见问题
Q 仪表盘数据保留多久?
A 默认 90 天。可通过
dashboard.data_retention 配置,支持 7-365 天。Q Web 仪表盘需要额外安装吗?
A 不需要。
hermes dashboard --web 直接启动内置 Web 服务,浏览器访问即可。Q 数据会泄露吗?
A 仪表盘数据仅存储在本地。Web 版默认只监听 localhost,不对外暴露。
Q 可以导出数据吗?
A
hermes stats export --format csv 导出所有统计数据。支持 CSV、JSON 格式。Q 多用户的仪表盘是分开的吗?
A 是的。每个 Profile 有独立的统计数据。管理员可查看全局汇总。
Q 告警支持哪些通知渠道?
A Telegram、Slack、Email、Webhook。可配置多个通知渠道。
📖 小节
- 仪表盘提供 CLI 文本版和 Web 图形版
- 核心指标:成本、Token、响应时间、工具调用、记忆
- 成本分析:按模型/任务类型/时间段
- 健康检查:Agent 各组件状态实时监控
- 告警:成本超限、延迟飙升、磁盘不足等
📝 作业
- 基础题(难度⭐):运行
hermes dashboard,查看当前统计数据,截图关键指标。 - 进阶题(难度⭐⭐):配置月度预算和告警,模拟成本超限场景,验证告警触发。
- 挑战题(难度⭐⭐⭐):设计一套自定义仪表盘面板,包含你最关心的 5 个指标,配置 Web 仪表盘布局。