GROK Custom Pattern help. Drop leading and trailing spaces

Looking to GROK the following data
"(DATA: SOME STUFF)"
What I am after is "SOME STUFF". When I use the following
\(DATA: (?<DATA> *(.+?) *)\)
I get this result in the debugger
{ "DATA": "SOME STUFF" }
but if my data looks like this "(DATA: SOME STUFF )"
I get this result { "DATA": "SOME STUFF " } with trailing spaces. Basically I DO NOT want the leading or trailing spaces around SOME STUFF. How can I drop these?

Use mutate+gsub to remove them.

mutate { gsub => [ "DATA", "^\s+", "", "DATA", "\s+$", "" ] }

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.