Metric-server cpu and memory units

Using metrics server I am getting cpu and memory usage of a pod.
for ex: “usage”:{“cpu”:“576285n”,“memory”:“182792Ki”}
Wanted to know what is the unit of cpu usage and memory here?
Is the metric value returned is CPU usage%?

n stands for “nanocores” or “nanoCPU”. Kubernetes CPU metrics are generally “expressed” when a person deals with them in millicores/milliCPU, or 1/1000 of a cpu. a nanocore/nanoCPU is 1/1000000000 (1 billionth) of a cpu. for a little more info the docs have a section on CPU Units but they only really describe millicores/milliCPU.

Ki is a Kibibyte. Kubernetes supports both Binary Units and Metric Units when writing pod specs and such, but for metrics things are emitted as Binary Units.


Can we convert this nanocores to CPU usage percentage?

It sort of is. Millicores came about to be a better approximation of CPU since “true” CPU% or allocation can vary depending on the platform.

Think of cpu usage set to 50%. 50% means different things on a system with 1 core vs 8 cores. With Millicores 1000m will always equal 1 core. If you see something consuming 750m you know it is roughly 75% of a single core. With that, if you want to approximate CPU %, you would:

current millicore usage / (cores * 1000)

Hope that makes sense :sweat_smile:


I’d add that for me it was also relevant to know which percentage of the requested to that pod was used by that pod.

So, instead of dividing by cores *1000, just divide by the requested.

Both numbers might be useful, in my case this one was more useful for developers so they knew they when they were using a big percentage of what was guaranteed and react (either reduce cpu usage or increase the request).


Thanks @mrbobbytables and @rata. This helped me alot. :slight_smile: