Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker stats for docker containers in kubernetes returning empty values

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

like image 935
Sujai Sivasamy Avatar asked Sep 27 '16 14:09

Sujai Sivasamy


People also ask

What is PIDs in Docker stats?

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.

How do I get container metrics?

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.

How do I enable Kubernetes on a docker container?

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.

What is a docker environment?

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.

Where does Docker stats get its memory usage data?

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.

What is the Kubernetes server?

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.


1 Answers

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.

like image 178
Sujai Sivasamy Avatar answered Oct 06 '22 20:10

Sujai Sivasamy