---
title: "Get container stats based on resource usage"
method: GET
path: "/containers/{id}/stats"
tags: ["Container"]
---

# Get container stats based on resource usage

`GET /containers/{id}/stats`

This endpoint returns a live stream of a container’s resource usage
statistics.

The `precpu_stats` is the CPU statistic of the *previous* read, and is
used to calculate the CPU usage percentage. It is not an exact copy
of the `cpu_stats` field.

If either `precpu_stats.online_cpus` or `cpu_stats.online_cpus` is
nil then for compatibility with older daemons the length of the
corresponding `cpu_usage.percpu_usage` array should be used.

## Path parameters

- `id` string, required

## Query parameters

- `stream` boolean

## Response `200`

container stats

- ContainerStats — container stats almost from cgroup resource usage.
  - `read` string, date-time — read time of container stats.
  - `id` string — container id
  - `name` string — container name
  - `pids_stats` PidsStats — PidsStats contains the stats of a container's pids
    - `current` integer — Current is the number of pids in the cgroup
    - `limit` integer — Limit is the hard limit on the number of pids in the cgroup. A "Limit" of 0 means that there is no limit.
  - `networks` object
  - `memory_stats` MemoryStats — MemoryStats aggregates all memory stats since container inception on Linux.
    - `usage` integer — current res_counter usage for memory
    - `max_usage` integer — maximum usage ever recorded.
    - `stats` object — all the stats exported via memory.stat.
    - `failcnt` integer — number of times memory usage hits limits.
    - `limit` integer — xxx
  - `blkio_stats` BlkioStats — BlkioStats stores All IO service stats for data read and write.
    - `io_service_bytes_recursive` BlkioStatEntry[]
      - `major` integer
      - `minor` integer
      - `op` string
      - `value` integer
    - `io_serviced_recursive` BlkioStatEntry[]
      - `major` integer
      - `minor` integer
      - `op` string
      - `value` integer
    - `io_queue_recursive` BlkioStatEntry[]
      - `major` integer
      - `minor` integer
      - `op` string
      - `value` integer
    - `io_service_time_recursive` BlkioStatEntry[]
      - `major` integer
      - `minor` integer
      - `op` string
      - `value` integer
    - `io_wait_time_recursive` BlkioStatEntry[]
      - `major` integer
      - `minor` integer
      - `op` string
      - `value` integer
    - `io_merged_recursive` BlkioStatEntry[]
      - `major` integer
      - `minor` integer
      - `op` string
      - `value` integer
    - `io_time_recursive` BlkioStatEntry[]
      - `major` integer
      - `minor` integer
      - `op` string
      - `value` integer
    - `sectors_recursive` BlkioStatEntry[]
      - `major` integer
      - `minor` integer
      - `op` string
      - `value` integer
  - `cpu_stats` CPUStats — CPUStats aggregates and wraps all CPU related info of container
    - `cpu_usage` CPUUsage — CPUUsage stores All CPU stats aggregated since container inception.
      - `total_usage` integer — Total CPU time consumed.
      - `percpu_usage` integer[] — Total CPU time consumed per core (Linux).
      - `usage_in_kernelmode` integer — Time spent by tasks of the cgroup in kernel mode (Linux). Units, nanoseconds (Linux)
      - `usage_in_usermode` integer — Time spent by tasks of the cgroup in user mode (Linux). Units, nanoseconds (Linux)
    - `syetem_cpu_usage` integer — System CPU Usage
    - `online_cpus` integer — onine CPUs
    - `throttling_data` ThrottlingData — ThrottlingData stores CPU throttling stats of one running container.
      - `periods` integer — Number of periods with throttling active.
      - `throttled_periods` integer — Number of periods when the container hits its throttling limit.
      - `throttled_time` integer — Aggregate time the container was throttled for in nanoseconds.
  - `precpu_stats` CPUStats — CPUStats aggregates and wraps all CPU related info of container
    - `cpu_usage` CPUUsage — CPUUsage stores All CPU stats aggregated since container inception.
      - `total_usage` integer — Total CPU time consumed.
      - `percpu_usage` integer[] — Total CPU time consumed per core (Linux).
      - `usage_in_kernelmode` integer — Time spent by tasks of the cgroup in kernel mode (Linux). Units, nanoseconds (Linux)
      - `usage_in_usermode` integer — Time spent by tasks of the cgroup in user mode (Linux). Units, nanoseconds (Linux)
    - `syetem_cpu_usage` integer — System CPU Usage
    - `online_cpus` integer — onine CPUs
    - `throttling_data` ThrottlingData — ThrottlingData stores CPU throttling stats of one running container.
      - `periods` integer — Number of periods with throttling active.
      - `throttled_periods` integer — Number of periods when the container hits its throttling limit.
      - `throttled_time` integer — Aggregate time the container was throttled for in nanoseconds.

## Other responses

- `404` — An unexpected 404 error occurred.
- `500` — An unexpected server error occurred.

---

[API](https://skmtc.dev/aliyun/apis/pouch-engine-api.md) · [All operations](https://skmtc.dev/aliyun/apis/pouch-engine-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/aliyun/pouch-engine-api/revisions/36d75b2825fc/schema)
