Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
15
Help us understand the problem. What is going on with this article?
@yungsang

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

More than 5 years have passed since last update.

@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
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
yungsang
Just another Otospermophilus beecheyi

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
15
Help us understand the problem. What is going on with this article?