Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Chapter 6

6.1 Monitoring Docker using CLI

Talk through slides

Docker CLI

  1. Run a container: docker container run -d --name db arungupta/couchbase

  2. docker container stats - You can use the docker container stats command to live stream a container’s runtime metrics. The command supports CPU, memory usage, memory limit, and network IO metrics.

  3. See the list of running containers using docker container ls and show stats for one container only

  4. docker container stats <name>

  5. docker container stats --format "{{.Container}}: {{.CPUPerc}}"

  6. docker container stats --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}"

  7. docker container stats --no-stream

Docker Remote API

  1. curl --unix-socket /var/run/docker.sock http://localhost/containers/<name>/stats

Events

  1. In one terminal (T1), docker system events

  2. In a different terminal (T2), kill a running container using docker container rm -f db

  3. Show the list of events in T1

  4. Start a new container in T2: docker container run -d jboss/wildfly

  5. Show the list of events in T1

6.2 Monitor Docker with Prometheus

Prometheus endpoint

Default metrics

  1. Update daemon settings:

    {
      "metrics-addr" : "0.0.0.0:1337",
      "experimental" : true
    }
  2. Restart Docker

  3. Show the list of metrics at curl http://localhost:1337/metrics

  4. Show the list of engine metrics at curl http://localhost:1337/metrics | grep engine

Prometheus node scraper

  1. Create a new directory prometheus and change directory

  2. Create prometheus.yml

    # A scrape configuration scraping a Node Exporter and the Prometheus server
    # itself.
    scrape_configs:
      # Scrape Prometheus itself every 5 seconds.
      - job_name: 'prometheus'
        scrape_interval: 5s
        static_configs:
          - targets: ['localhost:9090']
  3. Start Prometheus container:

    docker run \
      -d \
      --name metrics \
      -p 9090:9090 \
      -v `pwd`/prometheus.yml:/etc/prometheus/prometheus.yml \
      prom/prometheus
  4. Show the dashboard at http://localhost:9090

  5. Show the list of metrics

  6. Choose http_request_duration_microseconds

  7. Switch from Console to Graph

    1. Change the duration from 1h to 5m

  8. Stop the container: docker container rm -f metrics

6.3 Monitor Docker with cAdvisor

  1. Run cAdvisor

    docker run \
      -d \
      --name=cadvisor \
      -p 8080:8080 \
      --volume=/var/run:/var/run:rw \
      --volume=/sys:/sys:ro \
      --volume=/var/lib/docker/:/var/lib/docker:ro \
      google/cadvisor:latest
  2. Show dashboard at http://localhost:8080

    1. All Docker containers are in /docker sub-container

    2. Explain CPU and Memory isolation

    3. Explain CPU, Memory, Network, Filesystem usage

  3. Start Couchbase container:

    docker run \
      -d \
      --name db \
      -p 8091-8093:8091-8093 \
      arungupta/couchbase
  4. Refresh the dashboard

  5. Show Couchbase Web Console at http://localhost:8091

  6. Create a new bucket docker

  7. Create primary index in Query tab: create primary index on docker;

  8. Select documents from the bucket select * from docker;

  9. Refresh dashboard again