Question about docker cpu usage in %

Hi,

I am trying to get cpu usage (in percentage) of docker container. docker stats seems to work, but It’s just for display, it doesn’t give me the value as a variable. I tried the remote API, which shows the cpu usage in really complicated way that I don’t understand how to calculate the percentage out of it. cadvisor also doesn’t seem what I am looking for.

I am developing an application in java which runs inside the container, so I just need single cpu percentage that if it is more than certain threshold, raise an alert and tell another application (controller) that the load of that container is high do something.
Previously I used Sigar API to get the CPU load, but it is giving the cpu usage of host and not the container itself.

I appreciate any suggestions.

I have NOT used this myself however someone here mentioned it a while back …