elasticsearch:是一個基於Lucene構建的開源,分佈式,RESTful搜索引擎。設計用於雲計算中,能夠達到實時搜索,穩定,可靠,快速,安裝使用方便。
logstash:用來收集日誌,集成各種收集日誌插件。
kibana:爲 Logstash 和 ElasticSearch 提供的日誌分析的 Web 接口。
http://www.logstash.net/docs/1.4.2/
數據格式如下:
2014-09-04 09:38:00 /A/B/葉隨風(yesuifeng) 192.168.168.168 hhttp://www.logstash.net/docs/index.html allowed 2014-09-04 09:38:00 /A/B/C/葉(ye) 10.10.10.10 hhttp://www.logstash.net/docs/index.html allowed 2014-09-04 09:38:00 /A/D/隨風(suifeng) 172.16.10.10 hhttp://www.logstash.net/docs/index.html allowed
創建logstash配置文件,如下:
input{ file{ path => "/huang/tmp/1" start_position => "beginning" } } filter{ grok{ match => { "message" => "%{MYTESTLOG}" } } } output{ elasticsearch { host => localhost } stdout { codec => rubydebug } }
logstash/patterns下創建mylog文件,內容如下:
MYDATE %{YEAR}[/-]%{MONTHNUM}[/-]%{MONTHDAY} %{HOUR}:%{MINUTE}:%{SECOND} MYUSER /[^)]*\) MYTESTLOG %{MYDATE:ndate} %{MYUSER:nuser} %{IP:uip} %{URI:nurl} %{GREEDYDATA:nother}