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
+78
View File
@@ -1486,6 +1486,17 @@ definitions:
user_config_schema:
$ref: '#/definitions/channel.ConfigSchema'
type: object
handlers.ContainerCPUMetricsResponse:
properties:
kernel_nanoseconds:
type: integer
usage_nanoseconds:
type: integer
usage_percent:
type: number
user_nanoseconds:
type: integer
type: object
handlers.ContainerGPURequest:
properties:
devices:
@@ -1493,6 +1504,38 @@ definitions:
type: string
type: array
type: object
handlers.ContainerMemoryMetricsResponse:
properties:
limit_bytes:
type: integer
usage_bytes:
type: integer
usage_percent:
type: number
type: object
handlers.ContainerMetricsPayloadResponse:
properties:
cpu:
$ref: '#/definitions/handlers.ContainerCPUMetricsResponse'
memory:
$ref: '#/definitions/handlers.ContainerMemoryMetricsResponse'
storage:
$ref: '#/definitions/handlers.ContainerStorageMetricsResponse'
type: object
handlers.ContainerMetricsStatusResponse:
properties:
exists:
type: boolean
task_running:
type: boolean
type: object
handlers.ContainerStorageMetricsResponse:
properties:
path:
type: string
used_bytes:
type: integer
type: object
handlers.ContextUsage:
properties:
context_window:
@@ -1638,6 +1681,21 @@ definitions:
path:
type: string
type: object
handlers.GetContainerMetricsResponse:
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
type: object
handlers.GetContainerResponse:
properties:
cdi_devices:
@@ -4037,6 +4095,26 @@ paths:
summary: Write text content to a file
tags:
- containerd
/bots/{bot_id}/container/metrics:
get:
parameters:
- description: Bot ID
in: path
name: bot_id
required: true
type: string
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handlers.GetContainerMetricsResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/handlers.ErrorResponse'
summary: Get current container metrics for bot
tags:
- containerd
/bots/{bot_id}/container/skills:
delete:
parameters: