Docker Cookbook


| Chapter 9: Monitoring Containers



Download 6,31 Mb.
Pdf ko'rish
bet228/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   224   225   226   227   228   229   230   231   ...   260
Bog'liq
Docker Cookbook

290 | Chapter 9: Monitoring Containers


Several nonofficial images are used in this setup: 
gliderlabs/logsp‐
out

borja/unixbench

ehazlett/elasticsearch

ehazlett/kibana

eha‐
zlett/logstash
, and 
hopsoft/graphite-statsd
. Check the Dockerfile of
these images on Docker Hub or build your own images if you do
not trust them.
Once all the containers are up on the two hosts, and assuming that you set up the
networking and any firewall that may exist properly (open ports on security groups if
you are using cloud instances), you will be able to access the Nginx container on port
80 of the worker host, the Kibana dashboard on port 8080 of the monitor host, and
the Graphite dashboard on port 80 of the monitor host.
The Graphite dashboard will show you basic CPU metrics coming from all the con‐
tainers running on the worker host. See 
Figure 9-3
 for what you should see.
Figure 9-3. The Graphite dashboard showing CPU metrics for all containers
Discussion
You can get all the scripts used in this recipe by using the online material that comes
with this book. Clone the repository if you have not done so already and head over to
the 
docbook/ch09/collectd
directory:
$ git clone https://github.com/how2dock/docbook.git
$ cd docbook/ch09/collectd
$ tree
.
├── Dockerfile
├── README.md
├── Vagrantfile
9.9 Using Collectd to Visualize Container Metrics | 291


├── collectd.conf
├── docker-report.py
├── docker-stats.py
├── logstash.conf
├── monitor.yml
└── worker.yml
The Vagrantfile allows you to start two Docker hosts on your local machine to experi‐
ment with this setup. However, you can clone this repository in two cloud instances
that have Docker and Docker Compose installed and then start all the containers. If
you use Vagrant, do the following:
$ vagrant up
$ vagrant ssh monitor
$ vagrant ssh worker
While using Vagrant for this recipe, I encountered several intermit‐
tent errors as well as delays when downloading the images. Using
cloud instances with better network connectivity might be more
enjoyable.
The two YAML files are used to easily start all containers on the two hosts. Do not
run them on the same host:
$ docker-compose -f monitor.yml up -d
$ docker-compose -f worker.yml up -d
The 
logstash.conf
file was discussed in 
Recipe 9.6
. Go back to this recipe if you do not
understand this configuration file.
The Dockerfile is used to build a Collectd image and was shown in the solution sec‐
tion earlier. It is based on a Debian Jessie image and installs 
docker-py
(see 
Recipe
4.10
) and a few other scripts.
Collectd uses 
plug-ins
to collect metrics and send them to a data store (e.g., Carbon
with Graphite). In this setup, you use the simplest form of Collectd plug-in, which is
called an 
exec
plug-in. This is defined in the 
collectd.conf
file in the following section:
Exec "docker" "/opt/collectd/bin/docker-stats.py"
NotificationExec "docker" "/opt/collectd/bin/docker-report.py"
The Collectd process running in the foreground in the Collectd container will rou‐
tinely execute the two Python scripts defined in the configuration file. This is also
why you copy them in the Dockerfile. The 
docker-report.py
script outputs values to
syslog. This has the benefit that you will also collect them via your Logspout con‐
tainer and see them in your Kibana dashboard. The 
docker-stats.py
script uses the
Docker stats API (see 
Recipe 9.2
) and the 
docker-py
Python package. This script lists

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   224   225   226   227   228   229   230   231   ...   260




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish