0

We would like to monitor docker container metrics parameters like CPU, network, memory etc. we are following https://docs.docker.com/articles/runmetrics/ and found that monitoring metrics is not enabled by default.

cat /proc/cgroups 
#subsys_name        hierarchy   num_cgroups enabled
cpuset      1        7         1
cpu         2        7         1
cpuacct     3        7         1
memory      4        7         1
devices     5        7         1

As per the documentation we have to enable monitoring by setting up kernel parameters.

Memory Metrics: memory.stat

Memory metrics are found in the "memory" cgroup. Note that the memory control group adds a little overhead, because it does very fine-grained accounting of the memory usage on your host. Therefore, many distros chose to not enable it by default. Generally, to enable it, all you have to do is to add some kernel command-line parameters: cgroup_enable=memory swapaccount=1

Anyone knows how to set kernel parameters in docker container (Dockerfile or docker-compose.yml).

Thanks in Advance.

user2775185
  • 1,099
  • 3
  • 17
  • 30

1 Answers1

2

If your kernel supports cgroup_enable, you would add this at boot time, for instance on an Ubuntu machine:

edit /etc/default/grub.

update GRUB_CMDLINE_LINUX:

GRUB_CMDLINE_LINUX="cgroup_enable=memory"

then run sudo update-grub and reboot

If you are using CoreOS, it is already available.

Michael
  • 10,124
  • 1
  • 34
  • 49
  • Can you pls. help for centos ? – user2775185 Apr 14 '15 at 00:14
  • you can take a look in `/boot/grub/grub.conf` and remove any reference to `cgroup_disable=memory` and reboot – Michael Apr 14 '15 at 00:24
  • there is no file grub.conf. I installed yum install libcgroup then service cgroup start and below mentioned is error. Starting cgconfig service: Error: cannot mount cpuset to /cgroup/cpuset: Operation not permitted /sbin/cgconfigparser; error loading /etc/cgconfig.conf: Cgroup mounting failed Failed to parse /etc/cgconfig.conf or /etc/cgconfig.d [FAILED] – user2775185 Apr 14 '15 at 00:40