01 | input{ |
02 | file{ |
03 | path=> "/usr/local/elasticsearch-2.3.2/logs/elasticsearch.log.*" |
04 | type=> "elasticsearch" |
05 | start_position=> "beginning" |
06 | } |
07 |
08 | file{ |
09 | path=> "/var/log/secure" |
10 | type=> "secure" |
11 | start_position=> "beginning" |
12 | } |
13 | } |
14 |
15 | output{ |
16 | if [type] == "elasticsearch" { |
17 | elasticsearch { |
18 | hosts=> ["192.168.44.129:9200"] |
19 | index=> "elasticsearch-%{+YYYY-MM}" |
20 | } |
21 | } |
22 | if [type] == "secure" { |
23 | elasticsearch { |
24 | hosts=> ["192.168.44.129:9200"] |
25 | index=> "secure-%{+YYYY-MM}" |
26 | } |
27 | } |
28 | } |
上面的配置文件中用到的if条件判断是为了避免多个input的数据提交到Elasticsearch后共存于一个索引中。使用index参数来为每个不同的type建立单独的索引。运行Logstash后通过head插件查看下,可以看到新建立的索引名字
然后进入Kibana的设置界面增加索引信息,在第二个红框处输入之前logstash.conf文件中index参数所配置的名字,然后可以看到第三个红框处会自动匹配出来相关文件,最后点击create创建即可。
返回到Kibana的主界面,可以在左侧看到新创建出来的索引数据,可以在日志文件里随便加点东西,然后通过Kibana全文搜索也可以立即查看到,非常方便
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2018 群英 版权所有 茂名市群英网络有限公司
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号-36 粤公网安备 44090202000006号 粤工商备P091701000595