LoginSignup
15
15

More than 5 years have passed since last update.

@mopemope 氏の「CoreOS でシステムメトリクスを収集し、グラフ化する」を Vagrant で

Last updated at Posted at 2014-05-26

@mopemope 氏の docker - CoreOS でシステムメトリクスを収集し、グラフ化する - Qiita を Vagrant を使ってローカルで簡単にお試し出来る環境を作ってみようと思い立つ。

$ git clone git@github.com:YungSang/coreos-cluster.git -b graphite-diamond
$ cd coreos-cluster
$ vagrant up

ベースは https://github.com/YungSang/coreos-cluster なので、後は Graphite と Diamond のサービスを追加するだけ。

Etcd の discovery 用の VM に Graphite を、それ以外の各 VM に Diamond を追加しました。

discovery(vagrantfile-user-data)
    - name: graphite.service
      command: start
      runtime: no
      content: |
        [Unit]
        Description=Graphite Service
        After=docker.service
        Requires=docker.service

        [Service]
        ExecStartPre=/usr/bin/docker pull mopemope/graphite-docker
        ExecStart=/usr/bin/docker run -d --name %n -p 8081:81 -p 8080:80 -p 20030:2003 -p 2004 -p 7002 -p 8125:8125/udp -p 8126:8126 mopemope/graphite-docker
        #ExecStop=/usr/bin/docker stop -t 3 %n
        #ExecStopPost=/usr/bin/docker rm %n
        Restart=on-failure
        RestartSec=5s

なぜかサービスは上手く起動しているのに systemd 側では dead になるので ExecStop はコメントアウトすることに。

user-data(vagrantfile-user-data)
    - name: diamond.service
      command: start
      runtime: no
      content: |
        [Unit]
        Description=Diamond Service
        After=docker.service
        Requires=docker.service

        [Service]
        User=core
        ExecStartPre=/usr/bin/curl -L https://gist.github.com/mopemope/79476588ed3650bc08d4/raw/nspawn-container -o /home/core/nspawn-container
        ExecStartPre=/usr/bin/chmod +x /home/core/nspawn-container
        ExecStartPre=/usr/bin/docker pull mopemope/diamond-docker
        ExecStart=/bin/sh -c '/home/core/nspawn-container mopemope/diamond-docker /diamond/run_diamond %ETCD_DISCVERY% 20030'
        Restart=on-failure
        RestartSec=5s

Discovery での Graphite イメージのダウンロードと起動を待ちます。

これで VM の監視体制が整いました。

Graphite: http://localhost:8080
Grafana: http://localhost:8081

後は、Fleet を使ってクラスタにサービスをばらまくと、Docker を使ったアプリケーション(コンテナ)も Graphite 側に表示されるようになるはず。

15
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
15