LoginSignup
9
10

More than 5 years have passed since last update.

Logstash + Elasticsearch + Kibana4で簡易可視化

Last updated at Posted at 2015-10-27

忘備録
【OS】
今回はCentOS7.1_x86_64版を使用。詳細は以下を参照。
http://www.server-world.info/query?os=CentOS_7&p=install

事前準備
セットアップに必要なパッケージを事前に設定しておく必要がある。以下を全て設定する。
システム変更が発生するので管理者権限が必須。rootにsuしておく事。

【YUMパッケージ管理】
yum -y install yum-plugin-priorities
yum -y update
yum -y groupinstall "Base" "Development tools" "Japanese Support"
[EPELリポジトリ追加]
yum -y install epel-release
[Remiリポジトリ追加]
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
[RPMforgeリポジトリ追加]
yum -y install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
【Firewall無効】
systemctl stop firewalld
systemctl disable firewalld
【SELinux無効化】
vi /etc/selinux/config
SELINUX=enforcing
SELINUX=disabled ←変更(起動時に無効にする)

前提条件
既にJAVA+Elasticsearch+Kibana4はセットアップ済とする。

【Logstash】
公式サイトよりrpmを入手してインストール
https://www.elastic.co/downloads/logstash


wget https://download.elastic.co/logstash/logstash/packages/centos/logstash-1.5.4-1.noarch.rpm
rpm -ivh logstash-1.5.4-1.noarch.rpm

確認


$ /opt/logstash/bin/logstash --version
logstash 1.5.4
$ export PATH=$PATH:/opt/logstash/bin

Twitter AppsからTwitter Streaming APIを取得するためのアプリケーションを作成
https://apps.twitter.com/

image
適当に名前を付けます
image
利用許諾をチェックして[Create your Twitter application]ボタンをクリック
image
これでアプリケーションが出来上がりますので、Consumer Key、Consumer Secret Key、Access Token、Access Token Secretを取得します。

【Logstash実行】
inputとしてTwitterを指定し、全てのtweetを対象に、"aws"というキーワードで取得します。


logstash -e 'input { 
  twitter {
    consumer_key => "取得したConsumer Key (API Key)"
    consumer_secret => "取得したConsumer Secret Key (API Secret)"
    oauth_token => "取得したAccess Token"
    oauth_token_secret => "取得したAccess Token Secret"
    keywords => ["aws"]
    full_tweet => true
  }} 
output { 
    elasticsearch 
      { host => localhost
        port => "9200"
        protocol => "http"
        index => "twitter"
        document_type => "stream"
      } 
    stdout { } }'

【Kibanaで確認】

初期設定で、以下の通り対象とするindexを設定し、[Create]ボタンをクリックします。
image

[Discover]で確認。
image

9
10
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
9
10