FileBeat的版本为7.3.2,版本不同添加的参数不同!!!
为何要自定义模板?
因为我们在使用Kibana的时候有许多我们不需要分析的字段,这些字段的来源就是我们没有自定义FileBeat模板,FileBeat自带了N++个字段
。
编辑filebeat.yml文件,在output.elasticesearch模块下添加下面配置:
#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["cdh03:9200"]
index: "ngnix-%{+yyyy.MM}"
#因为我是分析ngnix 所以...
setup.template.name: "ngnix"
#这是指定分析索引为ngnix-开头的所有
setup.template.pattern: "ngnix-*"
#禁用自定义模板
setup.template.enabled: false
#覆盖原来的模板
setup.template.overwrite: true
#停用ilm 这一步很重要
setup.ilm.enabled: false
setup.ilm.enabled为false很是重要,因为filebeat在7.0以后的版本引入了索引的生命周期,如果不加最后一句,则会出现下方的启动log。
2020-05-21T14:27:26.382+0800 INFO crawler/crawler.go:72 Loading Inputs: 1
2020-05-21T14:27:26.383+0800 INFO log/input.go:148 Configured paths: [/var/log/nginx/access.log]
2020-05-21T14:27:26.383+0800 INFO input/input.go:114 Starting input of type: log; ID: 10636558663013435218
2020-05-21T14:27:26.383+0800 INFO crawler/crawler.go:106 Loading and starting Inputs completed. Enabled inputs: 1
2020-05-21T14:27:26.383+0800 INFO cfgfile/reload.go:171 Config reloader started
2020-05-21T14:27:26.383+0800 INFO cfgfile/reload.go:226 Loading of config files completed.
2020-05-21T14:27:26.383+0800 INFO log/harvester.go:253 Harvester started for file: /var/log/nginx/access.log
2020-05-21T14:27:27.384+0800 INFO pipeline/output.go:95 Connecting to backoff(elasticsearch(http://cdh03:9200))
2020-05-21T14:27:27.387+0800 INFO elasticsearch/client.go:743 Attempting to connect to Elasticsearch version 7.3.2
2020-05-21T14:27:27.455+0800 INFO [index-management] idxmgmt/std.go:252 Auto ILM enable success.
2020-05-21T14:27:27.456+0800 INFO [index-management.ilm] ilm/std.go:134 do not generate ilm policy: exists=true, overwrite=false
2020-05-21T14:27:27.456+0800 INFO [index-management] idxmgmt/std.go:265 ILM policy successfully loaded.
2020-05-21T14:27:27.539+0800 INFO [index-management] idxmgmt/std.go:300 Write alias successfully generated.
2020-05-21T14:27:27.540+0800 INFO pipeline/output.go:105 Connection to backoff(elasticsearch(http://cdh03:9200)) established
重启FileBeat,进入Kibana验证
ps -ef |grep filebeat
kill -9 xxx
nohup ./filebeat -e -c filebeat.yml -d "Publish" & > nohup.out
在ES和Kibana上查看结果显示,
FileBeat的版本为7.3.2,版本不同添加的参数不同!!!