在 Glue 中为多行记录使用自定义分类器

Use a custom classifier in Glue for multi line records

我有一些格式如下的文件

AB1|STUFF|1234|

AB2|SF|STUFF|

AB1|STUFF|45670|

AB2|AF|STUFF|

每一位数据由'|'分隔一条记录由AB1行和AB2行的数据组成。

我想在 Glue 中使用自定义 grok 分类器,如下所示:

?<LINE1>(?:AB1)?|%{WORD:ignore1}|%{NUMBER:id}\|\n%{WORD:LINE2}|%{WORD:make}|%{WORD:stuff2}\|

这是一个多行 grok 表达式,用于从多行记录中提取数据,如上所示。我不确定 Glue 中的分类器如何工作任何评论或建议都会非常有帮助。

根据 Glue Documentation:

Grok patterns can process only one line at a time. Multiple-line patterns are not supported. Also, line breaks within a pattern are not supported.

我不确定实际问题是什么,如果您需要有关如何创建自己的分类器的一般指导,我建议您阅读 this and this