首页 > 解决方案 > 多行 Filebeat 模板不适用于 filebeat.inputs - 类型:filestream

问题描述

当filebeat.inputs:参数指定类型:filestream - 文件流的日志没有按照多行的要求分析时,我在Filebeat中遇到了多行处理问题。模式:'^[[0-9]{4}-[0-9]{2}-[0-9]{2}',在输出中,我看到行没有添加到行中,是使用日志文件中的单独行创建了新的单行消息。

如果在文件bat.inputs:参数中指定type:log,那么一切正常,符合多行的要求。模式:'^[[0-9]{4}-[0-9]{2}-[0-9]{2}' - 创建多行消息。

我的配置中没有正确指定什么?

filebeat.inputs:
 
     - type: filestream
 
       enabled: true
 
       paths:
         - C:\logs\GT\TTL\*\*.log
       fields_under_root: true
       fields:
         instance: xml
         system: ttl
         subsystem: GT
         account: abc
       multiline.type: pattern
       multiline.pattern: '^\[[0-9]{4}-[0-9]{2}-[0-9]{2}'
       multiline.negate: true
       multiline.match: after

标签: filestreamfilebeat

解决方案


为了让它工作,你应该有这样的东西:

filebeat.inputs:
 
     - type: filestream
 
       enabled: true
 
       paths:
         - C:\logs\GT\TTL\*\*.log
       fields_under_root: true
       fields:
         instance: xml
         system: ttl
         subsystem: GT
         account: abc
       parsers:
         - multiline:
             type: pattern
             pattern: '^\[[0-9]{4}-[0-9]{2}-[0-9]{2}'
             negate: true
             match: after

这有两个原因:

  1. 在撰写本文时,关于多行处理的一般文档未更新以反映对 fileinputstream 类型所做的更改。您可以在此页面上找到有关在解析器下为 fileinputstream 设置多行的信息:https ://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-filestream.html
  2. 我刚才提到的文档也是错误的(至少在撰写本文时)。该示例显示了在不缩进其子项的情况下配置多行解析器,这将不起作用,因为解析器不会初始化它下面的任何值。这个问题也在这里讨论:https ://discuss.elastic.co/t/filebeat-filestream-input-parsers-multiline-fails/290543/13 ,我希望它会在未来的某个时候得到修复。

推荐阅读