【问题标题】:Docker container stats in cloudwatchcloudwatch 中的 Docker 容器统计信息
【发布时间】:2018-07-19 23:04:23
【问题描述】:

我正在使用 Amazon AWS 免费套餐进行概念验证。我让 docker 在带有几个容器的 EC2 实例上运行。我知道您可以运行一些脚本来监控 EC2 实例的内存,但想知道是否有脚本可用于监控每个 docker 容器的 CPU/内存并将结果发送到 CloudWatch。

任何帮助将不胜感激。

【问题讨论】:

  • 您可以使用 weave-scope link。这是监控任何 docker 容器的非常好的工具。

标签: amazon-web-services docker amazon-cloudwatch


【解决方案1】:

在寻找选项之后。我没有找到任何特定的解决方案,可以将集装箱级别的统计信息发送到 Cloud Watch。

尽管如此,您可以重用Aws mon scripts 并解析命令 docker stats,大致类似于这样的漂移:

docker ps | tail -n +2 > dockerps.txt #all lines except the firts one.
running_containers = cat dockerps.txt | wc -l
for (i=0;i=running_containers;i++) {
    container_id = cat dockerps.txt |  tr -s ' ' | cut -d' ' -f1 | sed -n -e $ip
    image_name = cat dockerps.txt |  tr -s ' ' | cut -d' ' -f2 | sed -n -e $ip
    used_mem = docker stats --no-stream | grep $(cat dockerps.txt |  tr -s ' ' | cut -d' ' -f1 |  sed -n -e 3p) |  tr -s ' ' | cut -d' ' -f3
    #and now send it to cloudwatch using the mon script 
} 

或者去cAdvisor + prometheus.io + Grafana(这是我正在做的)

跟踪特定容器(例如 celery)的内存使用情况。我每分钟都在运行(使用 crontab):

docker ps | tail -n +2 > dockerps.txt
(echo -n  $(date)" " && docker stats --no-stream | grep $(cat dockerps.txt | grep celery |  tr -s ' ' | cut -d' ' -f1 ) |  tr -s ' ' | cut -d' ' -f3)

然后 filebeat 将所有输出发送到 elasticsearch 集群,我在其中有该值的图形,还需要在 logstash 中进行 grok 来解​​析它。或者你可以把它寄给普罗米修斯。

我希望这对某人有帮助

【讨论】:

  • 我可以知道在#and now send it to cloudwatch using the mon script做什么吗?
  • 要获取过去 12 小时的利用率统计信息,请运行以下命令:./mon-get-instance-stats.pl --recent-hours=12 有关更多信息,请阅读 AWS mon答案中的脚本链接:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-18
  • 1970-01-01
  • 1970-01-01
  • 2017-07-30
相关资源
最近更新 更多