The DevOps 2.1 Toolkit by Viktor Farcic

The DevOps 2.1 Toolkit by Viktor Farcic

Author:Viktor Farcic
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2017-05-03T07:32:07+00:00


Let's have a quick look at the metrics provided by the node-exporter service. We'll use the util service to retrieve the metrics:

UTIL_ID=$(docker ps -q --filter \

label=com.docker.swarm.service.name=util)

docker exec -it $UTIL_ID \

apk add --update curl drill

docker exec -it $UTIL_ID \

curl http://node-exporter:9100/metrics

A sample of the curl output is as follows:

# HELP go_gc_duration_seconds A summary of the GC invocation durations.

# TYPE go_gc_duration_seconds summary

go_gc_duration_seconds{quantile="0"} 0

go_gc_duration_seconds{quantile="0.25"} 0

go_gc_duration_seconds{quantile="0.5"} 0

go_gc_duration_seconds{quantile="0.75"} 0

go_gc_duration_seconds{quantile="1"} 0

go_gc_duration_seconds_sum 0

go_gc_duration_seconds_count 0

...

As you can see, the metrics are in the Prometheus-friendly format. Please explore the Node Exporter collectors (https://github.com/prometheus/node_exporter#collectors) for more information about the meaning of each metric. For now, you should know that most of the node information you would need is available and will be, later on, scraped by Prometheus.

Since we sent a request through Docker networking, we got a load-balanced response and cannot be sure which node produced the output. When we reach the Prometheus configuration, we'll have to be more specific and skip networks load balancing.

Now that we have the information about servers, we should add metrics specific to containers. We'll use cAdvisor also known as container Advisor.

The cAdvisor provides container users an understanding of the resource usage and performance characteristics of their running containers. It is a running daemon that collects, aggregates, processes, and exports information about running containers. Specifically, for each container it keeps resource isolation parameters, historical resource usage, histograms of complete historical resource usage and network statistics. This data is exported container and machine-wide. It has native support for Docker containers.

Let's create the service:

docker service create --name cadvisor \

-p 8080:8080 \

--mode global \

--network proxy \

--mount "type=bind,source=/,target=/rootfs" \

--mount "type=bind,source=/var/run,target=/var/run" \

--mount "type=bind,source=/sys,target=/sys" \

--mount "type=bind,source=/var/lib/docker,target=/var/lib/docker" \

google/cadvisor:v0.24.1

Just as with the node-exporter, the cadvisor service is global and attached to the proxy network. It mounts a few directories that allows it to monitor Docker stats and events on the host. Since cAdvisor comes with a web UI, we opened port 8080 that will allow us to open it in a browser.

Before we proceed, we should confirm that the service is indeed running:

docker service ps cadvisor

The output of the service ps is as follows (IDs are removed for brevity):

NAME IMAGE NODE DESIRED STATE

cadvisor... google/cadvisor:v0.24.1 swarm-3 Running

cadvisor... google/cadvisor:v0.24.1 swarm-2 Running

cadvisor... google/cadvisor:v0.24.1 swarm-1 Running

cadvisor... google/cadvisor:v0.24.1 swarm-5 Running

cadvisor... google/cadvisor:v0.24.1 swarm-4 Running

--------------------------------------------------------

CURRENT STATE ERROR PORTS

Running 3 seconds ago

Running 3 seconds ago

Running 3 seconds ago

Running 8 seconds ago

Running 3 seconds ago



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.