Docker Cookbook


| Chapter 9: Monitoring Containers



Download 6,31 Mb.
Pdf ko'rish
bet220/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   216   217   218   219   220   221   222   223   ...   260
Bog'liq
Docker Cookbook

280 | Chapter 9: Monitoring Containers


Once the package is installed, you need to configure 
td-agent
, telling it to match cer‐
tain events and redirect them to a specific 
location
. For example, to match all Docker
events (which by default are tagged with 
docker.
) and redirect them
to 
stdout
, edit the 
td-agent
configuration file 
/etc/td-agent/td-agent.conf
and add the
following line:

type stdout

Then restart the service:
$ sudo service td-agent restart
You are now ready to start using Fluentd to manage your Docker logs. Let’s start an
Nginx container and use this logging driver:
$ docker run -d -p 80:80 --name nginx --log-driver=fluentd nginx
Now if you access Nginx in your browser and then check the 
td-agent
log file, you will
see the Docker logs:
$ tail -n 3 /var/log/td-agent/td-agent.log
...
2015-08-17 13:41:10 docker.dc3a645abfaa: {"log":"192.168.33.1 ...,\
"container_id":"dc3a645abfaa...",\
"container_name":"/nginx",\
"source":"stdout"}
You see that the logs are prefixed with 
docker.
. If you wanted to pre‐
fix the logs with something else, you could specify a different Go template (currently
{{.ID}}

{{.FullID}}

{{.Name}}
). For example, to prefix the logs with the name of
the container, use the 
log-opt
option like so:
$ docker kill nginx
$ docker rm nginx
$ docker run -d -p 80:80 --name nginx \
--log-driver=fluentd \
--log-opt fluentd-tag=docker.{{.Name}} nginx
The logs will become similar to the following:
$ tail -n 3 /var/log/td-agent/td-agent.log
...
2015-08-17 13:43:45 docker./nginx: {"container_id":"e4152ad9bdba...",\
"container_name":"/stupefied_franklin",\
"source":"stdout",\
"log":"192.168.33.1 ...}
In this example, you redirected the logs to only the Fluentd logs themselves. This is
not extremely useful or practical. In a production deployment, you would redirect the
logs to a remote data store like 
elasticsearch

influxdb
, or 
mongoDB
, for example.

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   216   217   218   219   220   221   222   223   ...   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