続・パフォーマンス計測実験で Graphite も Docker に置き換えた

Graphite も Docker に置き換えた

前回、Sitespeed.io + Docker と Hosted Graphite で Web のパフォーマンス計測実験 の続きで Graphite 周辺を Docker に置き換えたログです。

Graphite + Grafana + (StatsD)

上記がすべて入っている Docker イメージを利用します。

sitespeed.io がサポートしているのは graphite のフォーマットなので statsd は使いませんが上記のイメージではポート 2003 も EXPOSE されているので、そっちを利用します。

  • 80: the Grafana web interface.
  • 2003: the StatsD port.
  • 8125: the StatsD port.
  • 8126: the StatsD administrative port.

ドキュメントに StatsD port って書いてあるけど大丈夫です (´ω`) マチガイ?

起動スクリプトなど

例によって。

Graphite 側

冒頭のイメージを使います。2003 ポートはホスト側に公開しないで、Sitespeed.io のほうに --link でつなぎます。

#!/bin/sh

docker run \
  -d \
  -p 12345:80 \ # ホスト側のポートは適当です
  -v /path/to/graphite-whisper/:/var/lib/graphite/storage/whisper \
  --name graphite \
  --restart=always \
  choopooly/grafana-graphite

もちろん、ホストのサーバーメトリクスを流すときは 2003 なり 8125 をホストに公開してください。

Sitespeed.io 側

--link <name>:<alias> で他のコンテナにアクセスできるようになるので、それを利用します。ほとんど前回と同じですが、--graphiteHost にリンク先コンテナのホスト名を指定します。

#!/bin/sh

docker run     \
  --privileged \
  --rm         \
  --link graphite:graphite \ # これで graphite にアクセスできるように
  -v /path/to/storedir:/sitespeed.io \
  sitespeedio/sitespeed.io \
  sitespeed.io \
  -u http://havelog.ayumusato.com \
  -b firefox \
  -n 5 \
  -d 0 \
  -r /tmp \
  --wptHost www.webpagetest.org \
  --wptKey WEB_PAGETEST_API_KEY\
  --connection mobile3gfast \
  --graphiteHost graphite \ # ここに --link で指定した alias を指定する
  --graphiteNamespace sitespeed \
  --graphiteData summary,rules,pagemetrics,timings \

補足 --link

--link/etc/hosts をアレしてくれます。

sudo docker run --rm --link graphite:graphite -t -i sitespeedio/sitespeed.io /bin/bash
root@:/sitespeed.io# cat /etc/hosts
172.17.0.50     894e5a29e7d2
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.49     graphite 32beb637af5b

こんな感じ。

おしまい

Graphite のスクリプトを叩いてデーモンを起動したら、Sitespeed.io のスクリプトは cron なり何なり任意の周期で実行すればOK。

蛇足ですが Sitespeed.io の出すメトリクス、SpeedIndex がやや怪しい? WPO-Foundation/RUM-SpeedIndex を使ってそうだけど、WebPagetest 使うなら wpt 以下の数値を取った方が見慣れた数量感で良さげです。

# RUM SpeedIndex らしいけど...? HTMLレポートだと単位が ms で謎
sitespeed.summary.example.com.timing.speedIndex

# こっちのが見慣れた数値で良いと思う
sitespeed.summary.example.com.timing.wpt.firstView.SpeedIndex
sitespeed.summary.example.com.timing.wpt.repeatView.SpeedIndex

こんな感じですかね。


Author

ahomuAyumu Sato

overflow, Inc.VPoE

東京資本で生きる名古屋の鳥類

Web 技術、組織開発、趣味など雑多なブログ。技術の話題は zenn にも分散して投稿しています。

Bio: aho.mu
X: @ahomu
Zenn: ahomu
GitHub: ahomu

Related

Latest

Archives

Tags

Search