Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GROK Multiline log parsing #102

Open
daggumalli opened this issue Aug 3, 2018 · 7 comments
Open

GROK Multiline log parsing #102

daggumalli opened this issue Aug 3, 2018 · 7 comments

Comments

@daggumalli
Copy link

I am trying to parse multiline logs using GROK.. but the result omitting new line. Example code below.

String log = "a|b|c|d"+"\n"+"e";
Pattern = (?m)(?<ErrMsg>.*)

Output is = ErrMsg = a|b|c|d

Any help would be appreicated!!!

@ottobackwards
Copy link
Contributor

This is because the .* pattern without the DOTALL doesn't evaluate past the newline.

@ottobackwards
Copy link
Contributor

I was able to get your sample to work with (?m)(?<ErrMsg>.*\\R.*)"

@gruselglatz
Copy link

I try to achieve to parse this log, with nifi which uses this lib. but i fail all the time:
In kibana and Graylog its working fine, but not with nifi. Can i trick it into not stopping at the End of a line. The (?m) flag doesn't help strangely.

2019-09-24 08:52:46,881 [INFO ] 00000000 Dashboard loading performance: 
	beforeLoadingComponentsAndPrompts: 1042 ms
	dashboardComponentsCreated: 2082 ms
	dashboardInitialContentLinkingComplete: 2160 ms
	dashboardInitialRenderComplete: 3285 ms
	path: /public/Dashboards/PVP/PVP_Einstieg_MO/PVP_Einstieg_MO.stdb
	browser: Chrome 79
	httpRequestCount: 32
	hasInputFilters: false
	InputComponentCount: 1
	TableComponentCount: 1
	CDFComponentCount: 1
	PreselectComponentCount: 2
	ContentGenerator: 55 ms
	CreateChartConfig (F2): 21 ms
	CreateChartConfig (F1): 14 ms
	Get CDA Parameter from CDA file (F2): 2 ms
	UserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3920.0 Safari/537.36
 [https-openssl-nio-9085-exec-547] (ams.plugin.api.LoggingAPI) 

@ottobackwards
Copy link
Contributor

No, Nifi literally reads line by line and passes each line to grok. If you are using Nifi what you could think of doing is using another processor to modify the content, like replacing "\n" with "|" or something, and then modifying your grok to account for the change. ReplaceText processes could do this

@gruselglatz
Copy link

tried pretty much everything, but the problem is that it's in the flowfile between normal logs.
Do you know some magic to extract only this log from the others?

i tried it with nearly everything i found online and created this regex which should extract only this messages, but nifi handles it different and now I think i resign -.-

(^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2},\d{3}\s\[.*\s{0,3}\]\s\d{8}\sDashboard\sloading\sperformance:.*(?:(?:\r\n|[\r\n])(?!\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2},\d{3}\s\[.*\s{0,3}\]\s\d{8}).*)*(?:\r\n|[\r\n])?)

Is there not a single option to enable multiline in nifi grok? or can i fork it and recompile a new processor with this option enabled? (I am no java dev :( )

@ottobackwards
Copy link
Contributor

ottobackwards commented Sep 26, 2019 via email

@ottobackwards
Copy link
Contributor

ottobackwards commented Sep 26, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants