Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker stats shows different data compared to cadvisor

I have 2 Docker containers running on Centos machine

for Docker memory monitoring purpose, I have installed "cadvisor" on the machine via Docker images

when I compare "Docker stats" and "cadvisor" value then I see that cadvisor shows more memory usage than docker stats

for example, the value of memory usage in Docker stats command for one container is 520 MiB but in cadvisor value is 756 MiB

Which one is right ?

like image 592
Devendra Avatar asked Jan 02 '23 04:01

Devendra


1 Answers

According to Docker docs:

On Linux, the Docker CLI reports memory usage by subtracting page cache usage from the total memory usage.

https://docs.docker.com/engine/reference/commandline/stats/

So, to get from cAdvisor the same value as docker stats show, you can use the following expression: container_memory_usage_bytes - container_memory_cache

I tried it out and got exactly the same values as docker stats produces.

like image 197
amoskaliov Avatar answered Feb 15 '23 01:02

amoskaliov