filebeat支持processors的js脚本,但是有些地方还是不够完善,个人见解
详细脚本如下:
filebeat.inputs:
- type: log
enabled: true
paths:
- E:/20210223/*.log
setup.template.enabled: false
setup.ilm.enabled: false
processors:
- script:
lang: javascript
id: startWithHello
source: >
function process(event) {
var str = event.Get("message");
if(new RegExp('\\|').test(str)){
event.Tag(str);
}else{
event.Tag("no hello");
}
}
- drop_fields:
fields: ["ecs","agent","log","message"]
output.console:
pretty: true
注意:script对特殊字符处理