Hi Techrunnr, This document deals with the we looked into how we can use the API built into our containers to gain an insight to what resources our containers are running. Here we are using cAdvisor (Container Advisor) from google to collect the metrics of our containers.

  • cAdvisor running daemon that collects, aggregates, processes, and exports information about
    running containers
  • cAdvisor written in go language, we can compile our own binary file as well as already compiled file in container, which is already available in Google docker hub
  • Once installation was finished, cAdvisor will sit in background and collects the metrics like docker stats command
  • when we execute the any docker container it will stores the container data in /var/lib/doker, so we will mount this directory to cAdvisor, and /var/run, /sys
  • While running cAdvisor we will give –previleged=true, cAdvisor runs on 8080 port, so we mount this 8080 port to our host
  • We are going to run google/cAdvisor as shown below
    docker run \
    --detach=true \
    --volume=/:/rootfs:ro \
    --volume=/var/run:/var/run:rw \
    --volume=/sys:/sys:ro \
    --volume=/var/lib/docker/:/var/lib/docker:ro \
    --publish=8080:8080 \
    --privileged=true \
    --name=cadvisor \
    google/cadvisor:latest

    Note: When a container is launched with –privileged , Docker will enable full access to
    devices on the host machine; also, Docker will configure both AppArmor or SELinux to
    allow your container the same access to the host machine as a process running outside the
    container will have

  • open you browser with 8080 port, we can see a GUI of cAdvisor
  • for testing I am running 2 more services (NGinx, MongoDB)
  • In GUI mode below docker containers, this will have details of running containers
  • Overview section gives us container usage gauge ( Container loads)
  • Processes sections gives us ps aux , dockerps and top commands
  • CPU section gives us CPU utilization over the last minute, in total usage, load per core,  usage breakdown
  • Memory, this scetion splits into two parts, The graph tells you the total amount of
    memory used by all the processes for the host or container; this is the total of the hot and
    cold memory. The Hot memory is the current working set: pages that have been touched
    by the kernel recently. The Cold memory is the page that hasn’t been touched for a while
    and could be reclaimed if needed. The Usage Breakdown gives a visual representation of the total memory in the host machine, or allowance in the container, alongside the total and hot usage
  • Network Section gives us incoming and outgoing traffic over the last minute
  • File system section gives break down of the filesystem usage
  • The biggest drawback of using the web interface for cAdvisor is
    that it only shows you one minute’s worth of metrics

© 2019, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points

0 Comments

Leave a Reply

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.