下载安装包。
下载地址:https://www.elastic.co/cn/downloads/beats/filebeat
解压安装包。并配置【filebeat.yml】文件。
注:具体支持的输出方式可以参考官网:https://www.elastic.co/guide/en/beats/filebeat/current/configuring-output.html
以日期开头合并的多行:
filebeat.inputs: - type: log enabled: true paths: - G:/log/*.log multiline: #正则,以日期开头的合并多行 pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}' negate: true match: after max_lines: 1000 timeout: 3s output.elasticsearch: hosts: ["127.0.0.1:9200"] index: "actionlog-%{+yyyy.MM}" setup.template.name: "actionlog" setup.template.pattern: "actionlog-*" setup.ilm.enabled: false
以<数字>开头合并多行:
filebeat.inputs: - type: log #是否开启配置,此处需要设置true enabled: true #监控目录 paths: - G:/log/*.log multiline: pattern: '^<[0-9]+' negate: true match: after timeout: 10s #输出ES output.elasticsearch: hosts: ["127.0.0.1:9200"] index: "actionlog-%{+yyyy.MM}" setup.template.name: "actionlog" setup.template.pattern: "actionlog-*" setup.ilm.enabled: false
优化文件只读取一次,1分钟不更新就关闭监控的方案:
filebeat.inputs: - type: log #是否开启配置,此处需要设置true enabled: true # 检查文件更新的频率 # 默认是 10s scan_frequency: 10s #只读取一次文件,读取完成之后,关闭收割机 close_eof: true # 如果一个文件在某个时间段内没有发生过更新则关闭监控的文件handle。默认1h,change只会在下一次scan才会被发现 close_older: 1m #即当文件名称有变化时,包括改名和删除,会自动关闭一个文件 force_close_files: true #监控目录 paths: - G:/log/*.log multiline: pattern: '^<[0-9]+' negate: true match: after timeout: 10s #输出ES output.elasticsearch: hosts: ["127.0.0.1:9200"] index: "actionlog-%{+yyyy.MM}" setup.template.name: "actionlog" setup.template.pattern: "actionlog-*" setup.ilm.enabled: false
以<数字>开头合并多行并输出的KafKa:
filebeat.inputs: - type: log #是否开启配置,此处需要设置true enabled: true # 检查文件更新的频率 # 默认是 10s scan_frequency: 10s #只读取一次文件,读取完成之后,关闭收割机 close_eof: true # 如果一个文件在某个时间段内没有发生过更新则关闭监控的文件handle。默认1h,change只会在下一次scan才会被发现 close_older: 1m #即当文件名称有变化时,包括改名和删除,会自动关闭一个文件 force_close_files: true #监控目录 paths: - /monitor/log/*.log multiline: pattern: '^<[0-9]+' negate: true match: after timeout: 10s #输出KafKa output.kafka: hosts: ["localhost:9092"] topic: hillstonelog keep_alive: 10s第三步
启动fileBeat。需要用cmd窗口启动。
.filebeat -e -c filebeat.yml
下载安装包。
下载地址:https://www.elastic.co/cn/downloads/beats/filebeat
将压缩包上传到指定目录并解压
tar -zxvf filebeat-7.14.1-linux-x86_64.tar.gz
配置【filebeat.yml】文件。
注:具体支持的输出方式可以参考官网:https://www.elastic.co/guide/en/beats/filebeat/current/configuring-output.html
启动fileBeat。
./filebeat -e -c filebeat.yml
#后台启动
nohup ./filebeat -e -c filebeat.yml > /dev/null 2>&1 &
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)