Upgrade to Pro — share decks privately, control downloads, hide ads and more …

コンテナのメトリクスと モニタリングパターン / 190320-sakura-event

コンテナのメトリクスと モニタリングパターン / 190320-sakura-event

Hayato Imai

March 20, 2019
Tweet

More Decks by Hayato Imai

Other Decks in Technology

Transcript

  1. $ docker run -v $(pwd):/data alpine /bin/sh -c 'echo "hello

    world" >/data/hello' $ cat hello hello world e.g. Bind mounts
  2. ϩά • ΞϓϦέʔγϣϯͷSTDOUT • docker logs ίϚϯυ • kubectl logs

    ίϚϯυ • ίϯςφ಺ͷϩάϑΝΠϧ • σʔλϘϦϡʔϜ, Bind mountsΛར༻
  3. $ CONTAINER=$(docker run -d alpine /bin/sh -c 'while true; do

    date; sleep 1; done') $ docker logs --since 3s $CONTAINER Tue Mar 19 10:07:57 UTC 2019 Tue Mar 19 10:07:58 UTC 2019 Tue Mar 19 10:07:59 UTC 2019 e.g. docker logs
  4. $ curl http://${CONTAINER_IPADDR}/nginx_status Active connections: 43 server accepts handled requests

    7368 7368 10993 Reading: 0 Writing: 5 Waiting: 38 e.g. Nginxͷstub_status
  5. $ curl -s --unix-socket \ /var/run/docker.sock http://localhost/${CONTAINER}/stats?stream=false | \ jq

    . [...] "cpu_stats": { "cpu_usage": { "total_usage": 963481062, "percpu_usage": [ 431767249, 531713813 ], [...] e.g. Docker stats API
  6. $ docker stats --no-stream CONTAINER ID NAME CPU % MEM

    USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS d7f9c5c0acfc app 0.00% 1.945MiB / 1.952GiB 0.10% 1.5kB / 0B 5.11MB / 0B 2 8c484a94aca7 monitor 0.19% 652KiB / 1.952GiB 0.03% 1.41kB / 0B 1.24MB / 0B 2 e.g. docker stats
  7. $ cat /proc/${CONTAINER_PID}/net/dev Inter-| Receive | Transmit face |bytes packets

    errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ecs-eth0: 467809174 273650 0 0 0 0 0 0 27453834 328421 0 0 0 0 0 0 eth0: 30877420 169783 0 0 0 0 0 0 55160434 183407 0 0 0 0 0 0 e.g. /proc/PID/net/dev
  8. e.g. DockerͷωοτϫʔΫϞʔυ • bridge, none • Private Network Mode •

    ίϯςφ͝ͱʹಠཱͨ͠ΠϯλʔϑΣʔε • host, container • Shared Network Mode • ϗετϓϩηε΍ଞͷίϯςφͱڞ௨ͷΠϯλʔϑΣʔε
  9. MackerelίϯςφΤʔδΣϯτ(ύϒϦοΫϕʔλ) • ECS Task/Kubernetes Podઐ༻ͷϞχλϦϯάΤʔδΣϯτ • Sidecar Monitoring AgentΛ࠾༻ •

    কདྷతʹFargateͷΑ͏ͳΠϯϑϥετϥΫνϟͷ؅ཧ͕ෆཁͳίϯςφϓϥοτ ϑΥʔϜ͕ओྲྀʹͳΔͱߟ͍͑ͯΔ • ܰྔΤʔδΣϯτͱͯ͠࠶ઃܭͯ͠ϦιʔεফඅΛܰݮ • ΫϥελΤʔδΣϯτͷAPI͔ΒϦιʔεϝτϦΫεΛऔಘ • SidecarʹΑΔϦιʔεڞ༗ʹΑΓ؂ࢹର৅ͷΞϓϦέʔγϣϯ࢓༷ʹ͍ۙ؂ࢹ͕Մೳ