1

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 .

Shahidh
  • 2,472
  • 1
  • 18
  • 18
Shayeeb Ahmed
  • 74
  • 1
  • 1
  • 16

1 Answers1

1

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I need to write a custom agent that collects the resource metrics and calculate the usage from the metrics.The api endpoint above is giving me the metrics but i couldnt get more details about them to calculate stats like cpu ,memory,io usage etc.., – Shayeeb Ahmed Mar 07 '18 at 04:25
  • @ShayeebAhmed You will find examples in the source of that project: https://github.com/kubernetes/heapster/search?utf8=%E2%9C%93&q=cpu&type=. But the main point of that answer is: you don't have to write an endpoint: heapster *is* an endpoint, already written for you. Deploy it and you are good to go. – VonC Mar 07 '18 at 07:14
  • @ShayeebAhmed As an example, see https://github.com/kubernetes/heapster/commit/8f19d2a0b9f76a53cec231adbf224778bfad981d – VonC Mar 07 '18 at 07:15
  • Thank you @VonC I wanted to know how heapster is calculating these metrics. Is it possible.If so can u please guide me through this. – Shayeeb Ahmed Mar 07 '18 at 11:19
  • @ShayeebAhmed It uses Kubernetes API calls, coded in https://github.com/kubernetes/heapster/tree/master/metrics/apis/metrics/v1alpha1 – VonC Mar 07 '18 at 12:13
  • I think I found the solution for my problem by looking into your references.thank u very much. – Shayeeb Ahmed Mar 08 '18 at 04:58