feat(container): add current container metrics view

Expose a dedicated container metrics endpoint and surface current CPU, memory, and root filesystem usage in the bot container view. This gives operators a quick health snapshot while degrading cleanly on unsupported backends.
This commit is contained in:
Acbox
2026-04-24 15:10:47 +08:00
parent 8136ef6ed6
commit e4aca0db13
20 changed files with 1198 additions and 6 deletions
+121
View File
@@ -1503,6 +1503,37 @@ const docTemplate = `{
}
}
},
"/bots/{bot_id}/container/metrics": {
"get": {
"tags": [
"containerd"
],
"summary": "Get current container metrics for bot",
"parameters": [
{
"type": "string",
"description": "Bot ID",
"name": "bot_id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.GetContainerMetricsResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/bots/{bot_id}/container/skills": {
"get": {
"tags": [
@@ -11653,6 +11684,23 @@ const docTemplate = `{
}
}
},
"handlers.ContainerCPUMetricsResponse": {
"type": "object",
"properties": {
"kernel_nanoseconds": {
"type": "integer"
},
"usage_nanoseconds": {
"type": "integer"
},
"usage_percent": {
"type": "number"
},
"user_nanoseconds": {
"type": "integer"
}
}
},
"handlers.ContainerGPURequest": {
"type": "object",
"properties": {
@@ -11664,6 +11712,56 @@ const docTemplate = `{
}
}
},
"handlers.ContainerMemoryMetricsResponse": {
"type": "object",
"properties": {
"limit_bytes": {
"type": "integer"
},
"usage_bytes": {
"type": "integer"
},
"usage_percent": {
"type": "number"
}
}
},
"handlers.ContainerMetricsPayloadResponse": {
"type": "object",
"properties": {
"cpu": {
"$ref": "#/definitions/handlers.ContainerCPUMetricsResponse"
},
"memory": {
"$ref": "#/definitions/handlers.ContainerMemoryMetricsResponse"
},
"storage": {
"$ref": "#/definitions/handlers.ContainerStorageMetricsResponse"
}
}
},
"handlers.ContainerMetricsStatusResponse": {
"type": "object",
"properties": {
"exists": {
"type": "boolean"
},
"task_running": {
"type": "boolean"
}
}
},
"handlers.ContainerStorageMetricsResponse": {
"type": "object",
"properties": {
"path": {
"type": "string"
},
"used_bytes": {
"type": "integer"
}
}
},
"handlers.ContextUsage": {
"type": "object",
"properties": {
@@ -11889,6 +11987,29 @@ const docTemplate = `{
}
}
},
"handlers.GetContainerMetricsResponse": {
"type": "object",
"properties": {
"backend": {
"type": "string"
},
"metrics": {
"$ref": "#/definitions/handlers.ContainerMetricsPayloadResponse"
},
"sampled_at": {
"type": "string"
},
"status": {
"$ref": "#/definitions/handlers.ContainerMetricsStatusResponse"
},
"supported": {
"type": "boolean"
},
"unsupported_reason": {
"type": "string"
}
}
},
"handlers.GetContainerResponse": {
"type": "object",
"properties": {