filestream - 多行 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
解决方案
为了让它工作,你应该有这样的东西:
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
这有两个原因:
- 在撰写本文时,关于多行处理的一般文档未更新以反映对 fileinputstream 类型所做的更改。您可以在此页面上找到有关在解析器下为 fileinputstream 设置多行的信息:https ://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-filestream.html
- 我刚才提到的文档也是错误的(至少在撰写本文时)。该示例显示了在不缩进其子项的情况下配置多行解析器,这将不起作用,因为解析器不会初始化它下面的任何值。这个问题也在这里讨论:https ://discuss.elastic.co/t/filebeat-filestream-input-parsers-multiline-fails/290543/13 ,我希望它会在未来的某个时候得到修复。
推荐阅读
- kubernetes - Kubernetes:POD 的 CPU 资源分配
- google-cloud-platform - “Cloud build Custom Worker”现在可用吗?
- javascript - 如何在 AWS DynamoDb js sdk 中使用 begin_with?
- swift - 升级到 Catalina 后,Emacs 无法在 swift 模式下运行代码
- mysql - “使用索引”和复合索引:A=, B=, C<=
- excel - 将列值移动到下一行
- reactjs - axios.post 返回 400 React Native 的错误请求
- vue.js - 在 VueJs 中在 data() 和 created() 中声明对象有什么区别
- graphql - 运行 e2e 测试时在 cypress 中模拟特定的 graphql 请求
- vba - 如何从 ms 访问中调用 dll?