Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 69aae6c

Browse files
vivanov-dpthaJeztah
authored andcommitted
docs: add example calculations to container stats API
Signed-off-by: Velko Ivanov <vivanov@deeperplane.com> (cherry picked from commit 441211986c847ef08ec1d40432e2ec86a7ae1741) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 0c6bdf5974b0f0328ccad081db15cca6d4e20749 Component: engine
1 parent bf77a77 commit 69aae6c

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

components/engine/api/swagger.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5861,6 +5861,16 @@ paths:
58615861
If either `precpu_stats.online_cpus` or `cpu_stats.online_cpus` is
58625862
nil then for compatibility with older daemons the length of the
58635863
corresponding `cpu_usage.percpu_usage` array should be used.
5864+
5865+
To calculate the values shown by the `stats` command of the docker cli tool
5866+
the following formulas can be used:
5867+
* used_memory = `memory_stats.usage - memory_stats.stats.cache`
5868+
* available_memory = `memory_stats.limit`
5869+
* Memory usage % = `(used_memory / available_memory) * 100.0`
5870+
* cpu_delta = `cpu_stats.cpu_usage.total_usage - precpu_stats.cpu_usage.total_usage`
5871+
* system_cpu_delta = `cpu_stats.system_cpu_usage - precpu_stats.system_cpu_usage`
5872+
* number_cpus = `lenght(cpu_stats.cpu_usage.percpu_usage)` or `cpu_stats.online_cpus`
5873+
* CPU usage % = `(cpu_delta / system_cpu_delta) * number_cpus * 100.0`
58645874
operationId: "ContainerStats"
58655875
produces: ["application/json"]
58665876
responses:

0 commit comments

Comments
 (0)