v1
latestSwagger 2.02026-07-17108109409.0 KBGet container stats based on resource usage
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.
On a cgroup v2 host, the following fields are not set
- blkio_stats: all fields other than io_service_bytes_recursive
- cpu_stats: cpu_usage.percpu_usage
- memory_stats: max_usage and failcnt Also, memory_stats.stats fields are incompatible with cgroup v1.
To calculate the values shown by the stats command of the docker cli tool the following formulas can be used:
- used_memory = memory_stats.usage - memory_stats.stats.cache
- available_memory = memory_stats.limit
- Memory usage % = (used_memory / available_memory) * 100.0
- cpu_delta = cpu_stats.cpu_usage.total_usage - precpu_stats.cpu_usage.total_usage
- system_cpu_delta = cpu_stats.system_cpu_usage - precpu_stats.system_cpu_usage
- number_cpus = lenght(cpu_stats.cpu_usage.percpu_usage) or cpu_stats.online_cpus
- CPU usage % = (cpu_delta / system_cpu_delta) * number_cpus * 100.0
Path parameters
ID or name of the container
Query parameters
Stream the output. If false, the stats will be output once and then it will disconnect.
Only get a single stat instead of waiting for 2 cycles. Must be used with stream=false.
Response
no error