安装准备:
filebeat-6.6.0-linux-x86_64.tar.gz
elasticsearch-6.2.4.tar.gz
强烈建议filebeat和es采用一个大版本,否则可能造成意向不到的问题!
elasticsearch-7.XX需要更高版本的java(11),而提高es的版本也需要提高filebeat的版本!
安装步骤:
[if !supportLists]1、 [endif]上传elasticsearch-6.2.4.tar.gz安装包,tar -zxvf elasticsearch-6.2.4.tar.gz 解压。
[if !supportLists]2、 [endif]创建es用户和用户组,并将es的目录权限赋予es用户和用户组(ES不能用root启动)
[if !supportLists]3、 [endif]配置好集群参数,启动es
[if !supportLists]4、 [endif]使用命令(如url http://localhost:9200)返回结果意味集群启动没有问题
[if !supportLists]5、 [endif]上传filebeat-6.6.0-linux-x86_64.tar.gz安装包至采集机,tar -zxvf filebeat-6.6.0-linux-x86_64.tar.gz解压。
[if !supportLists]6、 [endif]切至安装目录,vim filebeat.yml修改对应内容,如图:(注意配置文件缩进)
调度平台的日志默认存放在/logs/logs.log中,es集群配置多个可以用“,”隔开。如:
hosts:["10.10.31.5:9200","10.10.31.6:9200"]
配置文件设置
#filebeat.yml
filebeat.inputs:
- type: log
enabled: true
paths:
- /logs/logs.log
#请给出日志文件名
json.keys_under_root: true
json.overwrite_keys: true
exclude_files: ['.gz$']
# fields:
# component: nginx #添加标签,字段名不可与日志中重复
fields_under_root: true
tail_files: true
processors:
- drop_fields:
fields: ["ecs","agent","host","input"]
logging:
files:
rotateeverybytes: 10485760
output.elasticsearch:
hosts: ["10.2.15.54:9200"]
7、命令nohup ./filebeat -e -c filebeat.yml > filebeat.log & 启动
8、验证命令./filebeat test output,输出结果如图则正常:
9、查看es是否正常接收到日志
日志增大,则代表正常,可尝试使用
curl -H "Content-Type: application/json" http://10.2.15.54:9200/filebeat-6.6.0-2021.11.02/_search -d '{"query":{"term":{"ruleCode":{"value":"test02","boost":1.0}}}}'
命令进行验证