Elasticsearch
Docker
Kibana4
td-agent2

kibana4 beta2 @ dockerコンテナ

More than 3 years have passed since last update.

macのboot2docker上のdockerコンテナでcentos6+elasticsearch1.4+kibana4+td-agent2を立ててみる

サンプルでtd-agent2で収集したdstatの値を流し込む


コンテナセットアップ

OSコンテナのダウンロード

$ docker pull centos:centos6

Status: Downloaded newer image for centos:centos6

コンテナ起動

$ docker run --name kibana4 -t -i -p 5601:5601 centos:centos6 /bin/bash


必要なものインストール

# yum groupinstall 'Development tools'

〜省略〜
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
Package: centos-release-6-6.el6.centos.12.2.x86_64 (@CentOS/$releasever)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y # ←y enter
〜省略〜
Complete!

# yum install which
〜省略〜
Installed:
which.x86_64 0:2.19-6.el6

Complete!

# yum install wget
〜省略〜
Installed:
wget.x86_64 0:1.12-5.el6_6.1

Complete!

# yum install tar
〜省略〜
Installed:
tar.x86_64 2:1.23-11.el6

Complete!

# yum install sudo
Installed:
sudo.x86_64 0:1.8.6p3-15.el6

Complete!

# yum install curl-devel
Installed:
libcurl-devel.x86_64 0:7.19.7-40.el6_6.1

Dependency Installed:
libidn-devel.x86_64 0:1.18-2.el6

Complete!

# yum install dstat
〜省略〜
Installed:
dstat.noarch 0:0.7.0-1.el6

Complete!


jdkインストール

# yum install java-1.7.0-openjdk

〜省略〜
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
Package: centos-release-6-6.el6.centos.12.2.x86_64 (@CentOS/$releasever)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
〜省略〜
Installed:
java-1.7.0-openjdk.x86_64 1:1.7.0.71-2.5.3.1.el6

Dependency Installed:
alsa-lib.x86_64 0:1.0.22-3.el6 atk.x86_64 0:1.30.0-1.el6
avahi-libs.x86_64 0:0.6.25-15.el6 cairo.x86_64 0:1.8.8-3.1.el6
cups-libs.x86_64 1:1.4.2-67.el6 flac.x86_64 0:1.2.1-6.1.el6
fontconfig.x86_64 0:2.8.0-5.el6 freetype.x86_64 0:2.3.11-14.el6_3.1
gdk-pixbuf2.x86_64 0:2.24.1-5.el6 giflib.x86_64 0:4.1.6-3.1.el6
gnutls.x86_64 0:2.8.5-14.el6_5 gtk2.x86_64 0:2.24.23-6.el6
hicolor-icon-theme.noarch 0:0.11-1.1.el6 jasper-libs.x86_64 0:1.900.1-15.el6_1.1
jpackage-utils.noarch 0:1.7.5-3.12.el6 libICE.x86_64 0:1.0.6-1.el6
libSM.x86_64 0:1.2.1-2.el6 libX11.x86_64 0:1.6.0-2.2.el6
libX11-common.noarch 0:1.6.0-2.2.el6 libXau.x86_64 0:1.0.6-4.el6
libXcomposite.x86_64 0:0.4.3-4.el6 libXcursor.x86_64 0:1.1.14-2.1.el6
libXdamage.x86_64 0:1.1.3-4.el6 libXext.x86_64 0:1.3.2-2.1.el6
libXfixes.x86_64 0:5.0.1-2.1.el6 libXfont.x86_64 0:1.4.5-4.el6_6
libXft.x86_64 0:2.3.1-2.el6 libXi.x86_64 0:1.7.2-2.2.el6
libXinerama.x86_64 0:1.1.3-2.1.el6 libXrandr.x86_64 0:1.4.1-2.1.el6
libXrender.x86_64 0:0.9.8-2.1.el6 libXtst.x86_64 0:1.2.2-2.1.el6
libasyncns.x86_64 0:0.8-1.1.el6 libfontenc.x86_64 0:1.0.5-2.el6
libjpeg-turbo.x86_64 0:1.2.1-3.el6_5 libogg.x86_64 2:1.1.4-2.1.el6
libpng.x86_64 2:1.2.49-1.el6_2 libsndfile.x86_64 0:1.0.20-5.el6
libthai.x86_64 0:0.1.12-3.el6 libtiff.x86_64 0:3.9.4-10.el6_5
libvorbis.x86_64 1:1.2.3-4.el6_2.1 libxcb.x86_64 0:1.9.1-2.el6
pango.x86_64 0:1.28.1-10.el6 pixman.x86_64 0:0.32.4-4.el6
pulseaudio-libs.x86_64 0:0.9.21-17.el6 tcp_wrappers-libs.x86_64 0:7.6-57.el6
ttmkfdir.x86_64 0:3.0.9-32.1.el6 tzdata-java.noarch 0:2014j-1.el6
xorg-x11-font-utils.x86_64 1:7.2-11.el6 xorg-x11-fonts-Type1.noarch 0:7.2-9.1.el6

Complete!

# yum install java-1.7.0-openjdk-devel
〜省略〜
Installed:
java-1.7.0-openjdk-devel.x86_64 1:1.7.0.71-2.5.3.1.el6

Complete!


elasticsearchインストール

# rpm --import http://packages.elasticsearch.org/GPG-KEY-elasticsearch

# vi /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-1.4]
name=Elasticsearch repository for 1.4.x packages
baseurl=http://packages.elasticsearch.org/elasticsearch/1.4/centos
gpgcheck=1
gpgkey=http://packages.elasticsearch.org/GPG-KEY-elasticsearch
enabled=1

# yum install elasticsearch
Installed:
elasticsearch.noarch 0:1.4.0-1

Complete!


elasticsearch起動

# /etc/init.d/elasticsearch start

error: "Read-only file system" setting key "vm.max_map_count"
Starting elasticsearch: [ OK ]


kibana4 インストール

# cd /tmp

# wget https://download.elasticsearch.org/kibana/kibana/kibana-4.0.0-BETA2.tar.gz
--2014-11-22 13:26:47-- https://download.elasticsearch.org/kibana/kibana/kibana-4.0.0-BETA2.tar.gz
Resolving download.elasticsearch.org... 54.243.77.158, 54.225.133.195, 107.22.222.16, ...
Connecting to download.elasticsearch.org|54.243.77.158|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 22874131 (22M) [application/octet-stream]
Saving to: “kibana-4.0.0-BETA2.tar.gz”

100%[==============================================================================>] 22,874,131 821K/s in 49s

2014-11-22 13:27:37 (459 KB/s) - “kibana-4.0.0-BETA2.tar.gz” saved [22874131/22874131]
# tar zxvf kibana-4.0.0-BETA2.tar.gz
# cd kibana-4.0.0-BETA2/bin/
# ./kibana &


td-agent2インストール

# curl -L http://toolbelt.treasuredata.com/sh/install-redhat-td-agent2.sh | sh

〜省略〜
Installed:
td-agent.x86_64 0:2.1.2-0

Complete!


elasticsearch pluginダウンロード

# /opt/td-agent/embedded/bin/gem install fluent-plugin-elasticsearch --no-ri --no-rdoc -V


dstat pluginダウンロード

# /opt/td-agent/embedded/bin/gem install fluent-plugin-dstat --no-ri --no-rdoc -V


td-agent.conf編集

# vi /etc/td-agent/td-agent.conf

## OS Performance
<source>
type dstat
tag perf.dstat
option -lcmdn # ←ロードアベレージ、CPU、メモリ、ディスクIO、ネットワーク(Byte)の収集
delay 1 # ←周期の設定です(単位は秒)
</source>

## ElasticSearch Insert
<match perf.**>
type elasticsearch
type_name performance
include_tag_key true
tag_key tag
host 127.0.0.1
port 9200
logstash_format true
logstash_prefix perf
flush_interval 1s
</match>


td-agent起動

# /etc/init.d/td-agent start