容器监控

docker 自带的监控子命令

  • ps:docker ps | docker container ls
  • top:docker container top $name
  • stats:docker container stats

sysdig

sysdig 是一个轻量级的系统监控工具,同时它原生还支持容器。

docker container run -it --rm --name=sysdig --privileged=true \
          --volume=/var/run/docker.sock:/host/var/run/docker.sock \
          --volume=/dev:/host/dev \
          --volume=/proc:/host/proc:ro \
          --volume=/boot:/host/boot:ro \
          --volume=/lib/modules:/host/lib/modules:ro \
          --volume=/usr:/host/usr:ro \
          sysdig/sysdig
  • 交互界面
  • 实时性
  • 命令行操作

Weave Scope

weave scope 的最大特点是会自动生成一张 docker host 地图,直观地理解、监控和控制容器。

curl -L git.io/scope -o /usr/local/bin/scope
chmod a+x /usr/local/bin/scope
scope launch

Weave Scope 的访问地址为http://[Host IP]:4040/
在这里插入图片描述

cAdvisor

cAdvisor 是 google 开发的容器监控工具。
安装:

docker run \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--publish=8080:8080 \
--detach=true \
--name=cadvisor \
google/cadvisor:latest

通过 http://[Host IP]:8080 访问cAdvisor。

Prometheus

docker run -d -p 9100:9100 \
-v "/proc:/host/proc" \
-v "/sys:/host/sys" \
-v "/:/rootfs" \
--net=host \
prom/node-exporter \
--path.procfs /host/proc \
--path.sysfs /host/sys \
--collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"

prometheus.yml配置文件

global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.
  evaluation_interval: 15s # By default, scrape targets every 15 seconds.
  # scrape_timeout: 10s # is set to the global default (10s).

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
    monitor: 'codelab-monitor'

rule_files:
  # - "rules/node.rules"
  # - "rules2/*.rules"
  
scrape_configs:
  - job_name: 'prometheus'

    static_configs:
      - targets: ['localhost:9090','localhost:8080','localhost:9100','192.168.24.136:8080','192.168.24.136:9100']

运行 Grafana在 host 192.168.24.137 上执行如下命令:

docker run -d -i -p 3000:3000 \
-e "GF_SERVER_ROOT_URL=http://grafana.server.name" \
-e "GF_SECURITY_ADMIN_PASSWORD=secret" \
--net=host \
grafana/grafana
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值