10
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ElasticsearchAdvent Calendar 2015

Day 9

logstashでapacheのアクセスログをelasticsearchに送信し、kibanaでグラフ表示

Posted at

この記事は Elasticsearch Advent Calendar 2015 9日目です。
elasticsearchを初めて使ってみました。

参考

概念

種類 説明
logstash 今回は/var/log/apache2/access.logを監視。追記があればelasticsearchに送信
elasticsearch ログデータを蓄積
kibana elasticsearchのログデータを解析しグラフ化

elasticsearchとkibanaを起動

elasticsearchを起動(port9200,9300)
docker run -d --name elasticsearch \
  -p 9200:9200 \
  -p 9300:9300 \
  elasticsearch
kibanaを起動(port5601)
docker run -d \
  --name kibana4 \
  --link elasticsearch:es \
  -e ELASTICSEARCH_URL=http://es:9200 \
  -p 0.0.0.0:5601:5601 \
  kibana

logstashダウンロード

設定

~/test.conf
input { file { path=> "/var/log/apache2/access.log" } }

filter {
  grok {
    match => { "message" => "%{COMBINEDAPACHELOG}" }
  }
  date {
    match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
    locale => "en"
  }
}

output {
  elasticsearch { hosts => ["localhost:9200"] }
}
configtest
$ logstash --configtest -f test.conf
Configuration OK
実行方法
$ logstash -f test.conf

kibanaのグラフ設定

discover.png

visualize.png

graph.png

  • 右上にsaveボタンがあるので押下

おわりに

  • この組み合わせだとapache以外のログも簡単にグラフ化できますね。
10
13
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
10
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?