I am trying to get the stats of the containers that are running inside the kubernetes nodes via docker stats command. But unfortunately I am getting all the values as "0" for all the pod containers.
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
7dc5af9923b2 0.00% 0 B / 0 B 0.00% 0 B / 0 B 0 B / 0 B 0
I did the same with containers that I brought up manually via docker run command in the same node and I am getting proper values for those containers.
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
8be93c039a25 0.12% 133.3 MB / 3.892 GB 3.43% 0 B / 648 B 2.208 MB / 0 B 0
Is there any specific method to get the stats fot the pod containers other than this?
Note: docker version is 1.11.2 and kube version is 1.3.7
PIDs. the number of processes or threads the container has created. Running docker stats on multiple containers by name and id against a Linux daemon.
You can use the docker stats command to live stream a container's runtime metrics. The command supports CPU, memory usage, memory limit, and network IO metrics. The docker stats reference page has more details about the docker stats command.
To enable Kubernetes support and install a standalone instance of Kubernetes running as a Docker container, go to Preferences > Kubernetes and then click Enable Kubernetes. By default, Kubernetes containers are hidden from commands like docker service ls, because managing them manually is not supported.
The Docker environment also includes a container runtime as well as build and image management. A Docker container image is a lightweight, standalone, executable software package that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.
This value is collected by cAdvisor. Docker stats instead collects metric directly from operating system and specifically from the /sys/fs/cgroup/memory special files. Docker stats shows as memory usage the result of usage_in_bytes - cache.
The Kubernetes server runs locally within your Docker instance, is not configurable, and is a single-node cluster. The Kubernetes server runs within a Docker container on your local system, and is only for local testing. Enabling Kubernetes allows you to deploy your workloads in parallel, on Kubernetes, Swarm, and as standalone containers.
I resolved this one. I used the kubelet API to get the metrics for the node and well as for individual containers. The following API will return the metrics for a pod container.
http://<nodeIP>:10255/stats/<podName>/<containerName> - POST
This post that was suggested in the comments was much helpful.
This document has some more APIs to collect the metrics.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With