How to fetch multiline with ExtractGrok processor in ApacheNifi?

妖精的绣舞 提交于 2020-01-16 09:12:06

问题


I am going to convert a log file events (which is recorded by LogAttribute processor) to JSON.

I am using 'ExtractGroke' with this configuration:

STACK pattern in pattern file is (?m).*

Each log has this format:

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----------

I expect rest of the message after first line saved in log, but I get only first line -------------- request was received----------.

I check the expression in Grok Debugger and it works. but it doesn't work with NiFi.

How to config ExtractGrok to get all lines in log value?


回答1:


I found the solution, I replace (?m).* with this one (?s).* and it works.



来源:https://stackoverflow.com/questions/58981203/how-to-fetch-multiline-with-extractgrok-processor-in-apachenifi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!