请选择 进入手机版 | 继续访问电脑版

技术控

    今日:19| 主题:53286
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Docker Stats Monitoring: Taking Dockbeat for a Ride

[复制链接]
百年不腻好吗 发表于 2016-10-6 23:57:17
534 16

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

Docker Stats Monitoring: Taking Dockbeat for a Ride

Docker Stats Monitoring: Taking Dockbeat for a Ride

  There is no silver bullet. This is how I always answer those asking about the best logging solution for Docker. A bit pessimistic of me, I know. But what I’m implying with that statement is that there is no perfect method for gaining visibility into containers. Dockerized environments are distributed, dynamic, and multi-layered in nature, so they are extremely difficult to log.
   That’s not to say that there are no solutions — to the contrary. From Docker’s logging drivers to logging containers to using data volumes, there are plenty of ways to log Docker, but all have certain limitations or pitfalls. Logz.io users use a dedicated container that acts as a log collector by pulling Docker daemon events, stats, and logs into our ELK Stack (Elasticsearch, Logstash and Kibana).
   That’s why I was curious to hear about the first release of Dockbeat (called Dockerbeat prior to Docker’s new repo naming conventions) — the latest addition to Elastic’s family of beats, which is a group of different log collectors developed for different environments and purposes. Dockbeat was contributed by the ELK community and is focused on using the docker stats API to push container resource usage metrics such as memory, IO, and CPU to either Elasticsearch or Logstash.
   Below is a short review of how to get Dockbeat up and running as well as a few personal first impressions by me. My environment was a locally installedELK Stack and Docker on Ubuntu 14.04.
  Installing Dockbeat

   To get Dockbeat up and running, you can either build the project yourself or use the binary release on the GitHub repository . The former requires some additional setup steps (installing Go and Glide, for starters), and I eventually opted for the latter. It took just a few steps and proved to be pretty painless (an additional method is to run Dockbeat as a container — see the repo’s readme for more details).
   You will first need to download the source code and release package from: https://github.com/Ingensi/dockbeat/releases
  1. $ gitclone https://github.com/Ingensi/dockbeat.git
  2. $ wgethttps://github.com/Ingensi/dockbeat/releases/download/v1.0.0/dockbeat-v1.0.0-x86_64
复制代码
Configuring and Running Dockbeat

   Before you start Dockbeat, there is the matter of configurations. Since I used a vanilla installation with Docker and ELK installed locally, I did not need to change a thing in the supplied dockbeat.yml file.
  Dockbeat is configured to connect to the default Docker socket:
  1. dockbeat
  2.   socket: ${DOCKER_SOCKET:unix:///var/run/docker.sock}
复制代码
My local Elasticsearch was already defined in the output section:
  1. ### Elasticsearch as output
  2.      elasticsearch
  3.           hosts: [“localhost:9200”]
复制代码
Of course, if you’re using a remotely installed Elasticsearch or Logstash instance, you will need to change these configurations respectively.
  Before you start Dockbeat, you will need to grant execution permissions to the binary file:
  1. $ chmod +x dockbeat-v1.0.0-x86_64
复制代码
Then, to start Dockbeat, use the following run command:
  1. ./dockbeat-v1.0.0-x86_64 -c dockbeat-1.0.0/dockbeat.yml -v -e
复制代码
Please note: I used the two optional parameters (‘-v’, ‘-e’) to see the output of the run command, but these, of course, are not mandatory.
  Dockbeat then runs, and if all goes as expected, you should see the following lines in the debug output:
  1. 2016/09/18 09:13:40.851229 beat.go:173: INFOdockbeatsuccessfullysetup. Startrunning.
  2. 2016/09/18 09:13:40.851278 dockbeat.go:196: INFOdockbeat%!(EXTRAstring=dockbeatis running! HitCTRL-C to stopit.)
  3. 2016/09/18 09:14:47.101231 dockbeat.go:320: INFOdockbeat%!(EXTRAstring=Publishing %v events, int=5)
  4. ...
复制代码
It seems like all is working as expected, so my next step is to ping Elasticsearch:
  1. $ curllocalhost:9200/_cat/indices
复制代码
The output displayed displays a cross-section of Elasticsearch indices:
  1. yellowopendockbeat-2016.09.18 5 1 749 0 773.7kb 773.7kb
  2. yellowopen .kibana             1 1   1 0   3.1kb   3.1kb
复制代码
  The next step is to define the index pattern in Kibana. After clicking on the Setting tab in Kibana, I entered dockbeat.* in the index name/pattern field and selected the @timestamp filter to create the new index pattern:
  

Docker Stats Monitoring: Taking Dockbeat for a Ride

Docker Stats Monitoring: Taking Dockbeat for a Ride

  Now, all the metrics collected by Dockbeat and stored by Elasticsearch are listed in the Visualize tab in Kibana:
  

Docker Stats Monitoring: Taking Dockbeat for a Ride

Docker Stats Monitoring: Taking Dockbeat for a Ride

  Analyzing Container Statistics

   The metrics collected by Dockbeat via the docker stats API are pretty extensive and include container attributes, CPU usage, network statistics, memory statistics, and IO access statistics.
   To gain some more visibility into the log messages, I added some of the fields from the menu shown on the left in the above screenshot. I started with the ‘ type ’ and ‘ containerName ’ fields and then explored some of the other indexed fields.
  Querying options in Kibana are varied  — you can start with a free-text search for a specific string or use a field-level search. Field-level searches allow you to search for specific values within a given field with the following search syntax.
  To search for logs for a specific container, I entered the following query in Kibana:
  1. containerName: jolly_yalow
复制代码
The result:
  

Docker Stats Monitoring: Taking Dockbeat for a Ride

Docker Stats Monitoring: Taking Dockbeat for a Ride

  Free-text search is the simplest query method, but because we are analyzing metrics, it is not the best way to go about analyzing the statistics unless you are looking for a specific container name.
  Visualizing Container Stats

  Visualizations are one of the biggest advantages of working with ELK, and the sky’s the limit as far as the number of container log visualizations is concerned. You can slice and dice the stats any way you like — it all boils down to what data you want to see.
  Building visualizations in Kibana does require a certain amount of expertise, but the result is worthwhile. You can end up with a nice monitoring dashboard for your Docker containers.
  Here are a few examples.
  Number of Containers

   Sometimes it’s easy to lose track of the number of containers we have running. In a production environment, this number can easily reach twenty per host or more. To see a unique count of the running containers, I used the Metric visualization to display a count of the ‘ containerName ’ field:
  

Docker Stats Monitoring: Taking Dockbeat for a Ride

Docker Stats Monitoring: Taking Dockbeat for a Ride

  Average CPU/Memory/Network Over Time

  Another example is to create a line chart that visualizes the average resource consumption per container over time. The configuration below is for network stats, but the same configuration can be applied to all types of metrics — all you have to do is change the field that is used to aggregate the Y Axis in the chart.
  The configuration:
  

Docker Stats Monitoring: Taking Dockbeat for a Ride

Docker Stats Monitoring: Taking Dockbeat for a Ride

  The resulting line chart:
  

Docker Stats Monitoring: Taking Dockbeat for a Ride

Docker Stats Monitoring: Taking Dockbeat for a Ride

  Compiling these visualization into one dashboard is easy — it’s simply a matter of selecting the Dashboard tab and then manually adding the visualizations.
  The Bottom Line

  Dockbeat was easy to install and get up and running — it worked right out of the box in my local sandbox environment and required no extra configurations! If you’re looking for a lightweight monitoring tool, Dockbeat is a good way to start.
   As I said in the introduction, there is no perfect logging solution for Docker. Containers produce other useful output information including Docker daemon events (such as attach, commit, and copy) and Docker logs (where available), and these are not collected by Dockbeat even though they are necessary to get a more holistic monitoring view of a Dockerized environment.
  Looking ahead, this seems like the logical next addition for this community beat.
   

Docker Stats Monitoring: Taking Dockbeat for a Ride

Docker Stats Monitoring: Taking Dockbeat for a Ride

   Daniel Berman
   Daniel Berman is Product Evangelist at Logz.io. He is passionate about log analytics, big data, cloud, and family and loves running, Liverpool FC, and writing about disruptive tech stuff.



上一篇:15 Interesting JavaScript and CSS Libraries for October 2016
下一篇:What’s New in Logz.io — September 2016
lzy156 发表于 2016-10-7 06:14:09
百年不腻好吗今年多大了?
回复 支持 反对

使用道具 举报

蒋鑫 发表于 2016-10-7 06:30:23
沙发是我的,谁也不要抢!
回复 支持 反对

使用道具 举报

ieinq 发表于 2016-10-10 03:21:08
生前何必久睡,死后自会长眠……
回复 支持 反对

使用道具 举报

邓效 发表于 2016-10-11 13:43:03
前排支持下了哦~
回复 支持 反对

使用道具 举报

长发不失风采 发表于 2016-10-11 16:55:02
广告位,坐下看看
回复 支持 反对

使用道具 举报

zxlplayklc 发表于 2016-10-11 17:44:45
虫星人来了,都叫兽呢?
回复 支持 反对

使用道具 举报

玩偶的眼泪 发表于 2016-10-12 09:41:36
收藏了,怕楼主删了!
回复 支持 反对

使用道具 举报

webking 发表于 2016-10-31 22:50:30
谁喷了榴莲味儿的香水?
回复 支持 反对

使用道具 举报

民工甲 发表于 2016-11-1 06:11:04
来,来,干了这杯翔!
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )

© 2001-2017 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表