I'm looking for a way to gather container FS usage bytes in a way that's actually useful as a metric. container_fs_usage_bytes from cadvisor shows the disk space used on the partition used for /var/lib/docker, which is absolutely useless.
The value from docker ps --size (also visible in docker system df -v) would be far more useful Anyone know of other exporters that can do this?
For reference, here is the output from docker ps --size
$ docker ps -s
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE
5bcf6d4bff20 ubuntu:bionic "sleep 100000" 27 seconds ago Up 25 seconds ubuntu 34.6MB (virtual 97.8MB)
0df1749b5458 gcr.io/cadvisor/cadvisor:v0.36.0 "/usr/bin/cadvisor -…" 24 minutes ago Up 24 minutes (healthy) 0.0.0.0:8080->8080/tcp cadvisor 0B (virtual 184MB)
The only solution that I could come up with is to use
BaseUsage
definition instead offs.Usage
. This would unfortunately require to to compile that stuff in one kubelet binary compatible with your desired k8s version.fs_usage_bytes
reflect the amount of data stored in/var/lib/docker
for particular container. It comes fromUsage
property ofFsStats
object and it is compatible with differentCRI
. HoweverFsStats
has another property calledBaseUsage
which compatible only with Docker, and considering Docker builtin support future deprecation there might be a good reason why it's not used. According to description in the code,BaseUsage
contains the value that comes from Docker and it's likely to be the same with the size shown indocker ps -s
output.So you want to use
BaseUsage
type definition instead offs.Usage
:This is what is returned as
container_fs_usage_bytes
:To avoid breaking any existing process with swapping the return value you might want to add whole section like this: