0

我要将日志文件事件(由LogAttribute处理器记录)转换为 JSON。

我正在使用ExtractGrok此配置:

在此处输入图像描述

模式文件中的堆栈模式是(?m).*

每个日志都具有以下格式:

2019-11-21 15:26:06,912 INFO [Timer-Driven Process Thread-4] org.apache.nifi.processors.standard.LogAttribute LogAttribute[id=143515f8-1f1d-1032-e7d2-8c07f50d1c5a] logging for flow file StandardFlowFileRecord[uuid=02eb9f21-4587-458b-8cee-ad052cb8e634,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1574339166853-1, container=default, section=1], offset=0, length=0],offset=0,name=0df20cc1-3f93-49df-81b1-dac18318ccd9,size=0]
------------- request was received----------
Standard FlowFile Attributes
Key: 'entryDate'
    Value: 'Thu Nov 21 15:26:06 AST 2019'
Key: 'lineageStartDate'
    Value: 'Thu Nov 21 15:26:06 AST 2019'
Key: 'fileSize'
    Value: '0'
FlowFile Attribute Map Content
Key: 'filename'
    Value: '0df20cc1-3f93-49df-81b1-dac18318ccd9'
Key: 'http.context.identifier'
    Value: '9552bd22-ec3b-4ada-93a9-a5ce9b27de25'
Key: 'path'
    Value: './'
Key: 'uuid'
    Value: '02eb9f21-4587-458b-8cee-ad052cb8e634'
-------------- request was received----------

我希望在日志中保存第一行之后的其余消息,但我只得到第一行:

-------------- request was received----------

我检查了Grok Debugger中的表达式,它可以工作。但它不适用于 NiFi。

如何配置 ExtractGrok 以获取日志值中的所有行?

4

1 回答 1

1

我找到了解决方案,我(?m).*用这个替换(?s).*它并且它有效。

于 2019-11-21T18:18:42.403 回答