LXD API units for memory, disk, and cpu usage

(Ver 3.0.3) So on the endpoint /1.0/containers/myContainer/state, it returns values for memory, disk, and CPU usage, however i dont know what the units are for the numbers it provides?

cpu is in nanoseconds, disk and memory are in bytes

How does disk storage work? Container istelf says it has using 200MB of storage, whereas LXD reports it is using 1.1 MB

Also, is there a way to get current CPU usage as a percentage of its limit?

There is no way to get percentage of limit for CPU as that’s not something the cgroup controllers really provide in any meaningful way.

For the disk, you’re probably on zfs or a similar backend which does copy on write from image to the container. The disk usage is therefore how much actual disk usage the container consumed rather than the sum of all files in the container.

For ZFS, there is a configuration option to switch to using referenced space instead (refquota).