1.exclude_lines
filebeat.inputs:
- type: log
paths:
- /var/log/system.log
- /var/log/wifi.log
- type: log
paths:
- "/var/log/apache2/*"
exclude_lines: ['^DBG'] #删除以DBG开头的任何行
fields:
apache: true #使用fields配置选项将名为apache的字段添加到输出中。
fields_under_root: true
2.include_lines:
Filebeat只导出与列表中正则表达式匹配的行。默认情况下,将导出所有行。忽略空行。
以下示例将Filebeat配置为导出以ERR或WARN开头的任何行:
filebeat.inputs:
- type: log
paths:
- /var/log/system.log
- /var/log/wifi.log
- type: log
paths:
- "/var/log/apache2/*"
include_lines: ['^ERR', '^WARN'] #
fields:
apache: true #使用fields配置选项将名为apache的字段添加到输出中。
fields_under_root: true
3.同时有include_lines和exclude_lines
如果同时定义了include_ line和exclude_line行,则Filebeat首先执行include_ line,然后执行exclude_line行。这两个选项的定义顺序并不重要。include\u lines选项将始终在exclude_ lines选项之前执行,即使exclude_ lines出现在配置文件的include_ line之前。
以下示例导出包含sometext的所有日志行,但以DBG(调试消息)开头的行除外:
filebeat.inputs:
- type: log
paths:
- /var/log/system.log
- /var/log/wifi.log
- type: log
paths:
- "/var/log/apache2/*"
include_lines: ['sometext']
exclude_lines: ['^DBG']
fields:
apache: true #使用fields配置选项将名为apache的字段添加到输出中。
fields_under_root: true
4.exclude_files
希望Filebeat忽略的文件匹配的正则表达式列表。默认情况下不排除任何文件。
以下示例将Filebeat配置为忽略具有gz扩展名的所有文件: