container details: limits, sandbox flags and a live stats sample
Container details now carry the image id and the HostConfig resource limits
(CPU cores and shares, memory and swap bytes, pids, device requests) plus sandbox flags
(privileged, read-only rootfs, network mode, restart policy), with null meaning unlimited. A new
GET /api/v1/docker/containers/{name}/stats returns one live sample: CPU percent
of one core, memory working set, processes, block IO and network bytes. Peers
proxy the new route.
Env, labels, command lines and mounts are deliberately excluded from the payload.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
72fccc34f8
commit
0ff3520563
16 files changed
+947
-19
No files matched your search
+3
-2
@@ -29,7 +29,8 @@ Base: `http://127.0.0.1:1984`. Errors are `{"error":{"code","message"}}`.
|
||||
| `GET /api/v1/journal?unit=&priority=err&lines=100` | priority by name or number |
|
||||
| `GET /api/v1/journal/follow?unit=&priority=` | SSE, event `journal` |
|
||||
| `GET /api/v1/docker/ps` | `503` when Docker is unavailable |
|
||||
| `GET /api/v1/docker/containers/{name}` | |
|
||||
| `GET /api/v1/docker/containers/{name}` | limits and sandbox flags (`resources`), `image_id`; never env, labels or commands |
|
||||
| `GET /api/v1/docker/containers/{name}/stats` | one live sample: CPU percent, memory, pids, block IO, network |
|
||||
| `GET /api/v1/docker/containers/{name}/logs?tail=&since=&follow=0\|1` | JSON, or SSE with events `stdout`/`stderr` |
|
||||
| `GET /api/v1/peers` | consolidator only; sorted status list; absent when peers are disabled |
|
||||
| `GET /api/v1/peers/{peer}` | one peer's status object; unknown name is 404 |
|
||||
@@ -72,7 +73,7 @@ Present only when `[peers] enabled = true`. The same inbound token as the rest o
|
||||
|
||||
`server` is the TCP check and `api` is the authenticated ping. `auth` is `ok`, `rejected` or `unknown`. Before the first check, `up` is false, `auth` is `unknown` and the timestamps are null. An unknown name is `404` `{"error":{"code":"not_found","message":"peer <name>: unknown peer"}}`.
|
||||
|
||||
`GET /api/v1/peers/{peer}/{path}` forwards a GET to that peer and returns the peer's status and body. The path has to be one of the documented read routes: `systemd/units`, `systemd/units/{name}`, `systemd/timers`, `journal`, `journal/follow`, `docker/ps`, `docker/containers/{name}`, `docker/containers/{name}/logs`. `ping` and `peers/...` are not forwarded. `systemd/units/{name}` accepts exactly what the local route accepts, including escaped names (`mnt-data\x2dbackup.mount`, sent as `%5C`) and `-.mount`. `..`, encoded slashes, NUL/CRLF, a second encoding layer and any other path are `400` `peer <name>: path not allowed`. Query keys are the same ones the local route accepts (`state`, `unit`, `priority`, `lines`, `since`, `all`, `tail`, `follow`); anything else is `400` `peer <name>: unsupported query parameter`. The `unit` value is checked with the same unit-name rule as `systemd/units/{name}`, so escaped names work as both `%5C` and a literal backslash (`/api/v1/peers/beta/journal?unit=mnt-data%5Cx2dbackup.mount`). The caller's `Authorization` and `Cookie` are not forwarded; the consolidator sends the peer's own token.
|
||||
`GET /api/v1/peers/{peer}/{path}` forwards a GET to that peer and returns the peer's status and body. The path has to be one of the documented read routes: `systemd/units`, `systemd/units/{name}`, `systemd/timers`, `journal`, `journal/follow`, `docker/ps`, `docker/containers/{name}`, `docker/containers/{name}/stats`, `docker/containers/{name}/logs`. `ping` and `peers/...` are not forwarded. `systemd/units/{name}` accepts exactly what the local route accepts, including escaped names (`mnt-data\x2dbackup.mount`, sent as `%5C`) and `-.mount`. `..`, encoded slashes, NUL/CRLF, a second encoding layer and any other path are `400` `peer <name>: path not allowed`. Query keys are the same ones the local route accepts (`state`, `unit`, `priority`, `lines`, `since`, `all`, `tail`, `follow`); anything else is `400` `peer <name>: unsupported query parameter`. The `unit` value is checked with the same unit-name rule as `systemd/units/{name}`, so escaped names work as both `%5C` and a literal backslash (`/api/v1/peers/beta/journal?unit=mnt-data%5Cx2dbackup.mount`). The caller's `Authorization` and `Cookie` are not forwarded; the consolidator sends the peer's own token.
|
||||
|
||||
A request that already has `x-slinuxm-hop` is `400` `peer <name>: chained requests are not allowed`. Other methods are `405`. `journal/follow` and docker logs with `follow=1` are `text/event-stream` with `Cache-Control: no-cache`, like the local follow routes, cut off at `limits.max_follow_secs` or shutdown. Bodies larger than `peers.max_response_bytes` are `503` `peer <name>: oversize`. Only `2xx` from the peer is passed through; any other status becomes the section 4 error for that peer (a peer `404` is `404 not_found`, a peer `401`/`403` is `503 peer rejected credentials`, anything else is `503 http_<code>`), so a redirect or the peer's own error body never reaches the caller.
|
||||
|
||||
|
||||
@@ -197,6 +197,79 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/docker/containers/{name}/stats": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"docker"
|
||||
],
|
||||
"summary": "One live resource sample of a container",
|
||||
"description": "A single Docker stats sample: CPU percent, memory, processes, block IO and network counters. Read once per request, so a caller that wants a time series samples this endpoint itself.",
|
||||
"operationId": "get_container_stats",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
"in": "path",
|
||||
"description": "Container name or id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "The sample",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ContainerStats"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid container name",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorBody"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Missing or unknown bearer token",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorBody"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Unknown container",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorBody"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"503": {
|
||||
"description": "Docker socket is not available",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorBody"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/docker/ps": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -1244,6 +1317,244 @@
|
||||
"unknown"
|
||||
]
|
||||
},
|
||||
"ContainerDevice": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ids",
|
||||
"capabilities"
|
||||
],
|
||||
"properties": {
|
||||
"capabilities": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Capabilities such as `gpu`."
|
||||
},
|
||||
"count": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "int64",
|
||||
"description": "Devices requested; `None` with `ids` means \"as listed\"."
|
||||
},
|
||||
"driver": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"description": "`nvidia`, `cdi`, …"
|
||||
},
|
||||
"ids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Device ids as the driver names them, e.g. `nvidia.com/gpu=all`."
|
||||
}
|
||||
}
|
||||
},
|
||||
"ContainerResources": {
|
||||
"type": "object",
|
||||
"description": "Limits and sandbox flags taken from the container's `HostConfig`.\n\nDeliberately narrow: `Env`, `Labels`, `Cmd`, `Args` and mounts are never\ncopied, so nothing here can carry a secret.",
|
||||
"required": [
|
||||
"devices"
|
||||
],
|
||||
"properties": {
|
||||
"cpu_cores": {
|
||||
"type": [
|
||||
"number",
|
||||
"null"
|
||||
],
|
||||
"format": "double",
|
||||
"description": "CPU limit in cores (`nano_cpus`, else `cpu_quota`/`cpu_period`). `None` is unlimited."
|
||||
},
|
||||
"cpu_shares": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "int64",
|
||||
"description": "Relative CPU weight; Docker's default is 1024."
|
||||
},
|
||||
"devices": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ids",
|
||||
"capabilities"
|
||||
],
|
||||
"properties": {
|
||||
"capabilities": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Capabilities such as `gpu`."
|
||||
},
|
||||
"count": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "int64",
|
||||
"description": "Devices requested; `None` with `ids` means \"as listed\"."
|
||||
},
|
||||
"driver": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"description": "`nvidia`, `cdi`, …"
|
||||
},
|
||||
"ids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Device ids as the driver names them, e.g. `nvidia.com/gpu=all`."
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Device reservations, such as a CDI GPU request."
|
||||
},
|
||||
"memory_bytes": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "int64",
|
||||
"description": "Memory limit in bytes. `None` is unlimited."
|
||||
},
|
||||
"memory_swap_bytes": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "int64",
|
||||
"description": "Memory plus swap limit in bytes."
|
||||
},
|
||||
"network_mode": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"description": "`bridge`, `host`, `none`, or a compose network name."
|
||||
},
|
||||
"pids_limit": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "int64"
|
||||
},
|
||||
"privileged": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"read_only_rootfs": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"restart_policy": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ContainerStats": {
|
||||
"type": "object",
|
||||
"description": "One live sample from Docker's container stats endpoint.",
|
||||
"required": [
|
||||
"sampled_at"
|
||||
],
|
||||
"properties": {
|
||||
"block_read_bytes": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 0
|
||||
},
|
||||
"block_write_bytes": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 0
|
||||
},
|
||||
"cpu_percent": {
|
||||
"type": [
|
||||
"number",
|
||||
"null"
|
||||
],
|
||||
"format": "double",
|
||||
"description": "CPU use across all cores in percent (100 = one core fully busy)."
|
||||
},
|
||||
"memory_limit_bytes": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 0
|
||||
},
|
||||
"memory_percent": {
|
||||
"type": [
|
||||
"number",
|
||||
"null"
|
||||
],
|
||||
"format": "double"
|
||||
},
|
||||
"memory_used_bytes": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"description": "Working set: usage minus page cache.",
|
||||
"minimum": 0
|
||||
},
|
||||
"network_rx_bytes": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 0
|
||||
},
|
||||
"network_tx_bytes": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 0
|
||||
},
|
||||
"pids": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "uint64",
|
||||
"minimum": 0
|
||||
},
|
||||
"sampled_at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ContainerStatus": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -1295,6 +1606,13 @@
|
||||
"image": {
|
||||
"type": "string"
|
||||
},
|
||||
"image_id": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"description": "Content address of the image the container runs, e.g. `sha256:…`."
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "Name without the leading slash."
|
||||
@@ -1305,6 +1623,124 @@
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"resources": {
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"description": "Configured limits and sandbox flags. Never env, labels or command lines.",
|
||||
"required": [
|
||||
"devices"
|
||||
],
|
||||
"properties": {
|
||||
"cpu_cores": {
|
||||
"type": [
|
||||
"number",
|
||||
"null"
|
||||
],
|
||||
"format": "double",
|
||||
"description": "CPU limit in cores (`nano_cpus`, else `cpu_quota`/`cpu_period`). `None` is unlimited."
|
||||
},
|
||||
"cpu_shares": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "int64",
|
||||
"description": "Relative CPU weight; Docker's default is 1024."
|
||||
},
|
||||
"devices": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ids",
|
||||
"capabilities"
|
||||
],
|
||||
"properties": {
|
||||
"capabilities": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Capabilities such as `gpu`."
|
||||
},
|
||||
"count": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "int64",
|
||||
"description": "Devices requested; `None` with `ids` means \"as listed\"."
|
||||
},
|
||||
"driver": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"description": "`nvidia`, `cdi`, …"
|
||||
},
|
||||
"ids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Device ids as the driver names them, e.g. `nvidia.com/gpu=all`."
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Device reservations, such as a CDI GPU request."
|
||||
},
|
||||
"memory_bytes": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "int64",
|
||||
"description": "Memory limit in bytes. `None` is unlimited."
|
||||
},
|
||||
"memory_swap_bytes": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "int64",
|
||||
"description": "Memory plus swap limit in bytes."
|
||||
},
|
||||
"network_mode": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"description": "`bridge`, `host`, `none`, or a compose network name."
|
||||
},
|
||||
"pids_limit": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"format": "int64"
|
||||
},
|
||||
"privileged": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"read_only_rootfs": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"restart_policy": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"restart_count": {
|
||||
"type": [
|
||||
"integer",
|
||||
|
||||
Reference in new issue
Block a user