繁体   English   中英

无法使用grok处理logstash中文件拍的多行输入

[英]Cannot handle multiline input from filebeats in logstash with grok

我是Logstash的新手,并且在来自文件拍的Logstash中有以下多行输入:

"message":"[step info]\\nstep: 3\\ngrammar name: grammar1\\nnoInputTimeout: 6000\\nstep stream idle time: 14910\\nstep stream start time: 2017-12-01 17:06:10.024\\nrec start time: 2017-12-01 17:06:09.994\\nrec finish time: 2017-12-01 17:06:12.748\\nsystem prompt duration: 570\\nuser barged in: true\\nuser noInput time: 0\\nuser speech duration: 1190\\nspeech start trigger: 8265\\nspeech start on rec: 7945\\nspeech end trigger: 8415\\nspeech end on rec: 9135\\nrec completion cause: 000 success\\nrec completion type: SR\\nrec result: onetwothreefour\\nrec inputMode: speech\\nRTF: 0.47\\nrec process time: 557\\nrec latency: 61\\nrec post delay: 62"

我正在尝试找到带有grok的图案,但没有任何效果。 我也尝试了split和mutate,但无法使其正常工作。

这只是您尝试使用的指针,但是KV过滤器 (键值过滤器)可能会有所帮助。

查看您的示例,您可以执行以下操作。

kv {
  source => "message"
  field_split => "\n"
  value_split => ":"
}

这将以您为例

"message":"[step info]\nstep: 3\ngrammar name: grammar1\nnoInputTimeout: 6000\nstep stream idle time: 14910\nstep stream start time: 2017-12-01 17:06:10.024\nrec start time: 2017-12-01 17:06:09.994\nrec finish time: 2017-12-01 17:06:12.748\nsystem prompt duration: 570\nuser barged in: true\nuser noInput time: 0\nuser speech duration: 1190\nspeech start trigger: 8265\nspeech start on rec: 7945\nspeech end trigger: 8415\nspeech end on rec: 9135\nrec completion cause: 000 success\nrec completion type: SR\nrec result: onetwothreefour\nrec inputMode: speech\nRTF: 0.47\nrec process time: 557\nrec latency: 61\nrec post delay: 62"

然后在\\ n char上分割,然后从您拥有的示例中创建键值对,左侧将是字段名称,右侧将是值。

step: 3
grammar name: grammar1
noInputTimeout: 6000
step stream idle time: 14910
step stream start time: 2017-12-01 17:06:10.024
rec start time: 2017-12-01 17:06:09.994
rec finish time: 2017-12-01 17:06:12.748

如果您需要拆分[step info],则需要提供更多示例,但我将使用greedydata基本上将您的内容拆分为2个字段,其中1个为[step info],1个为[step lines]。并将分隔线作为上方KV滤波器的源字段。

希望这能为您指明正确的方向。

E.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM