udpate
This commit is contained in:
+164
-8
@@ -164,7 +164,7 @@ curl http://localhost:8000/agents?template=echo_agent
|
||||
|
||||
### 3. 获取 Agent 状态
|
||||
|
||||
获取指定 Agent 的详细状态信息。
|
||||
获取指定 Agent 的详细状态信息,包括 Pod 状态、容器健康状态、资源配额等。
|
||||
|
||||
**请求**
|
||||
|
||||
@@ -178,23 +178,168 @@ GET /agents/{agent_name}/status
|
||||
|------|------|------|
|
||||
| agent_name | string | Agent 名称 |
|
||||
|
||||
**响应**
|
||||
**响应 - 健康状态**
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "alice-echo",
|
||||
"namespace": "ai-agents",
|
||||
"status": "Running",
|
||||
"pod_ip": "10.244.2.24",
|
||||
"node_name": "aks-node-123",
|
||||
"health_status": "healthy",
|
||||
"template": "echo_agent",
|
||||
"created_at": "2026-01-05T07:35:00+00:00",
|
||||
"labels": {
|
||||
"user-id": "alice",
|
||||
"template": "echo_agent"
|
||||
}
|
||||
"node": "aks-node-123",
|
||||
"pod_ip": "10.244.2.24",
|
||||
"containers": [
|
||||
{
|
||||
"name": "alice-echo",
|
||||
"ready": true,
|
||||
"restart_count": 0,
|
||||
"state": "running",
|
||||
"started_at": "2026-01-05T07:35:15+00:00"
|
||||
}
|
||||
],
|
||||
"resources": {
|
||||
"requests": {
|
||||
"cpu": "100m",
|
||||
"memory": "128Mi"
|
||||
},
|
||||
"limits": {
|
||||
"cpu": "500m",
|
||||
"memory": "512Mi"
|
||||
},
|
||||
"usage": {
|
||||
"cpu": "14502n",
|
||||
"memory": "8704Ki",
|
||||
"available": true
|
||||
}
|
||||
},
|
||||
"service_port": 8080,
|
||||
"access_url": "http://10.244.2.24:8080",
|
||||
"endpoints": {
|
||||
"root": "http://10.244.2.24:8080/",
|
||||
"health": "http://10.244.2.24:8080/health"
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"type": "Ready",
|
||||
"status": "True",
|
||||
"reason": null
|
||||
},
|
||||
{
|
||||
"type": "ContainersReady",
|
||||
"status": "True",
|
||||
"reason": null
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**响应 - 崩溃状态**
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "my-mysql-agent",
|
||||
"namespace": "ai-agents",
|
||||
"status": "Waiting",
|
||||
"health_status": "unhealthy",
|
||||
"template": "mysql_agent",
|
||||
"created_at": "2026-01-04T06:40:38+00:00",
|
||||
"node": "aks-node-123",
|
||||
"pod_ip": "10.244.1.53",
|
||||
"containers": [
|
||||
{
|
||||
"name": "my-mysql-agent",
|
||||
"ready": false,
|
||||
"restart_count": 599,
|
||||
"state": "waiting",
|
||||
"reason": "CrashLoopBackOff",
|
||||
"message": "back-off 5m0s restarting failed container=my-mysql-agent pod=my-mysql-agent_ai-agents(...)"
|
||||
}
|
||||
],
|
||||
"resources": {
|
||||
"requests": {
|
||||
"cpu": "100m",
|
||||
"memory": "128Mi"
|
||||
},
|
||||
"limits": {
|
||||
"cpu": "500m",
|
||||
"memory": "512Mi"
|
||||
},
|
||||
"usage": {
|
||||
"cpu": null,
|
||||
"memory": null,
|
||||
"available": false,
|
||||
"reason": "metrics-server未安装或Pod不存在"
|
||||
}
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"type": "Ready",
|
||||
"status": "False",
|
||||
"reason": "ContainersNotReady"
|
||||
},
|
||||
{
|
||||
"type": "ContainersReady",
|
||||
"status": "False",
|
||||
"reason": "ContainersNotReady"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**字段说明**
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| name | string | Agent 名称 |
|
||||
| namespace | string | 命名空间 |
|
||||
| status | string | Pod 状态 (Running/Pending/Waiting/Terminated/Failed) |
|
||||
| **health_status** | string | **健康状态** (healthy/unhealthy/degraded) |
|
||||
| template | string | 使用的模板 |
|
||||
| created_at | string | 创建时间 (ISO 8601) |
|
||||
| node | string | 运行的节点 |
|
||||
| pod_ip | string | Pod IP 地址 |
|
||||
| **containers** | array | **容器详细状态** |
|
||||
| resources | object | 资源配额和使用情况 |
|
||||
| service_port | int \| null | 服务端口 |
|
||||
| access_url | string \| null | 访问地址 |
|
||||
| endpoints | object \| null | API 端点 |
|
||||
| conditions | array | Pod 条件状态 |
|
||||
|
||||
**健康状态说明**
|
||||
|
||||
| 状态 | 说明 |
|
||||
|------|------|
|
||||
| `healthy` | 所有容器运行正常且就绪 |
|
||||
| `unhealthy` | 容器崩溃、终止或未就绪 |
|
||||
| `degraded` | 容器重启次数过多 (>5次) |
|
||||
|
||||
**容器状态字段**
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| name | string | 容器名称 |
|
||||
| ready | boolean | 是否就绪 |
|
||||
| restart_count | int | 重启次数 |
|
||||
| state | string | 状态 (running/waiting/terminated) |
|
||||
| reason | string \| null | 状态原因 (如 CrashLoopBackOff) |
|
||||
| message | string \| null | 详细消息 |
|
||||
| exit_code | int \| null | 退出码 (terminated 状态) |
|
||||
| started_at | string \| null | 启动时间 (running 状态) |
|
||||
| finished_at | string \| null | 结束时间 (terminated 状态) |
|
||||
|
||||
**Pod 状态类型**
|
||||
|
||||
| 状态 | 说明 |
|
||||
|------|------|
|
||||
| Running | Pod 正在运行 |
|
||||
| Pending | Pod 等待调度 |
|
||||
| Waiting | 容器等待启动 |
|
||||
| Terminated | 容器已终止 |
|
||||
| Failed | Pod 失败 |
|
||||
| Succeeded | Pod 成功完成 |
|
||||
|
||||
**状态码**
|
||||
|
||||
- `200` - 成功
|
||||
@@ -204,9 +349,20 @@ GET /agents/{agent_name}/status
|
||||
**示例**
|
||||
|
||||
```bash
|
||||
# 查询健康的 Agent
|
||||
curl http://localhost:8000/agents/alice-echo/status
|
||||
|
||||
# 查询崩溃的 Agent
|
||||
curl http://localhost:8000/agents/my-mysql-agent/status
|
||||
```
|
||||
|
||||
**使用建议**
|
||||
|
||||
1. **监控告警**:使用 `health_status` 字段而非 `status` 进行健康监控
|
||||
2. **故障排查**:检查 `containers` 数组获取容器崩溃原因和重启次数
|
||||
3. **自动化运维**:根据 `health_status` 自动触发重启或告警
|
||||
4. **日志分析**:结合 `restart_count` 和 `reason` 定位问题
|
||||
|
||||
---
|
||||
|
||||
### 4. 获取 Agent 资源使用情况
|
||||
|
||||
Reference in New Issue
Block a user