LoginSignup
48
49

More than 5 years have passed since last update.

3分でEFK(ElasticSearch+Fluentd+Kibana)を構築する

Last updated at Posted at 2015-08-25

はじめに

  • 今更ながらかもしれませんが、EFK(ElasticSearch+Fluentd+Kibana)を試してみてます。
  • ちょっと試したいだけなのに一杯インストールせねばならんのですね。。。ということでEFK構成を構築するansibleのplaybookを作ってみました。良ければ使ってください。
  • Forwarder - https://github.com/uzresk/ansible-td-agent.git
  • EFK - https://github.com/uzresk/ansible-efk.git

3分で構築する前提事項

  • ansibleが使えること
  • gitが使えること(yum -y install gitとかで突っ込んでおいてください)
  • サーバを2台(sshで接続できればなんでもいいです)

こんな環境を作ります。

  • 左側はfluentdのforwarder。右側はログを集積するaggregatorと呼ばれます。
  • forwarderからaggregatorへはin_tailを使ってログを連携します。
  • aggregatorへ連携されたログはfluent-plugin-elasticsearchを使ってelasticsearchに入ります。
  • kibanaはelasticsearchの情報を閲覧するためのviewになります。同一のホスト上にある場合はデフォルトインストールされた状態で使うことができます。

スクリーンショット 2015-08-25 14.31.34.png

  • 今回は/var/log/secureの情報を、fluentd経由でelasticsearchにインデクシングさせてみます。

クライアント環境を作ります。(左側)

1.gitからソースを取得します。

  • このplaybookはtd-agentのインストール、サービス化、kernel、ulimitの設定をやってくれます。
  • 設定をちゃんと反映させるには再起動が必要です。
git clone https://github.com/uzresk/ansible-td-agent.git

2. inventoryファイルの対象ホストの情報を編集して

[server]
192.168.1.20

3. 実行

ansible-playbook -i hosts site.yml

ログ集積用のサーバ(右側)を構築します。

  • こちらも3stepです。

1.gitからソースを取得します。

このplaybookはこんなことをやってくれます。(設定をちゃんと反映させるには要再起動)

  • td-agentのインストール、kernel,ulimits設定
  • td-agent.confの設定、サービス化
  • fluent-plugin-elasticsearchのインストール
  • libcurlのインストール
  • jdk8のインストール
  • elastic search1.7.1のインストール、サービス化、起動
  • kibanaのインストール、サービス化、起動
  • apacheのインストール、プロキシの設定
git clone https://github.com/uzresk/ansible-efk.git

2. inventoryファイルの対象ホストの情報を編集します。

[server]
192.168.1.20

3. 実行

ansible-playbook -i hosts site.yml

動作を確認する。

  1. クライアント側のサーバにsshログインする。
  2. kibanaを開く(http://ログ集積サーバのIP/kibana/)
  3. Discoverタブ内でsecure*を選択し、Discoverで/var/log/secureのログが転送されてきていればOKです。
48
49
2

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
48
49