监控与运维
监控架构
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ RadStudio │────→│ Prometheus │────→│ Grafana │
│ Services │ │ (采集指标) │ │ (可视化) │
└──────────────┘ └──────────────┘ └──────────────┘
启用监控
# 启动监控服务
cd deploy
docker compose -f docker-compose.monitoring.yml up -d
监控服务
| 服务 | 端口 | 说明 |
|---|---|---|
| Prometheus | 9090 | 指标采集和存储 |
| Grafana | 3000 | 可视化仪表盘 |
监控指标
系统指标
- CPU 使用率
- 内存使用率
- 磁盘使用率
- 网络流量
应用指标
- API 请求量和延迟
- 任务队列长度
- 任务成功率/失败率
- 数据库连接数
GPU 指标
- GPU 使用率
- 显存使用率
- GPU 温度
健康检查
# API 健康检查
curl `http://localhost:8000/health`
# 服务状态
radstudioctl status
# 节点监控
curl -s `http://localhost:8000/internal/admin/nodes/stats` \
-H "Authorization: Bearer <admin_token>"
管理后台监控
管理后台 (http://localhost:8080) 提供可视化界面:
- 概览 — 系统整体统计(租户/用户/任务/项目)
- 节点管理 — Worker 节点列表 + 在线/离线状态
- 实时监控 — CPU / 内存 / 磁盘 / GPU 使用率(10s 刷新)
日志管理
# 查看服务日志
radstudioctl logs backend
radstudioctl logs frontend
radstudioctl logs celery-worker
# 实时跟踪日志
radstudioctl logs -f backend
备份策略
数据库备份
# 备份 PostgreSQL
docker exec postgres pg_dump -U radstudio radstudio > backup_$(date +%Y%m%d).sql
# 恢复
docker exec -i postgres psql -U radstudio radstudio < backup_20260609.sql
对象存储备份
# 使用 MinIO Client 备份
mc mirror local/radstudio-data backup/radstudio-data
告警配置
在 Prometheus 中配置告警规则:
# prometheus/alerts.yml
groups:
- name: radstudio
rules:
- alert: HighCPUUsage
expr: process_cpu_seconds_total > 0.8
for: 5m
labels:
severity: warning
annotations:
summary: "CPU 使用率过高"