How to calculate cpu usage, memory usage from the metrics returned by Kubernetes kublet summary endpoint ie., <machine-ip>:10255/stats/summary

3/6/2018

below is the metrics returned by the kubelet summary endpoint

"node":{
        "nodeName":"shayeeb-virtualbox",
        "systemContainers":[ ],
        "startTime":"2018-03-05T04:52:39Z",
        "cpu":{
            "time":"2018-03-05T05:06:00Z",
            "usageNanoCores":989865279,
            "usageCoreNanoSeconds":861395314766
        },
        "memory":{
            "time":"2018-03-05T05:06:00Z",
            "availableBytes":697614336,
            "usageBytes":1809657856,
            "workingSetBytes":1378811904,
            "rssBytes":935657472,
            "pageFaults":56928,
            "majorPageFaults":70
        },
        ...

the cpu metric is returned in ns but i need to calculate the cpu usage from the above metric and further more I need to calculate the memory usage from the above memory metrics.I am stuck here I couldnt find any details about the above metrics .

-- Shayeeb Ahmed
heapster
kubelet
kubernetes

1 Answer

3/6/2018

As mentioned in K8s Managing Compute Resources for Containers/ "Monitoring compute resource usage":

The resource usage of a Pod is reported as part of the Pod status.

If optional monitoring is configured for your cluster, then Pod resource usage can be retrieved from the monitoring system.

That optional monitoring system would be kubernetes/heapster, which enables Container Cluster Monitoring and Performance Analysis for Kubernetes (versions v1.0.6 and higher).
It includes... a lot of metrics.

-- VonC
Source: StackOverflow