Capturing only first group in Logstash regex

Hello everyone!

Can someone explain me next please.
I have log:

"bool":{"must":[{"bool":{"should":[{"codesearch_score_query":{"query_id":"9baec4c4-d910-4023-899e-5a580bfbd3a3","query":{"term":{"content":"copy"}}}},{"function_score":{"boost":10000000,"query":{"term":{"fileName":{"_name":"fileName_copy","value":"copy"}}}}}]}},{"bool":{"should":[{"codesearch_score_query":{"query_id":"9baec4c4-d910-4023-899e-5a580bfbd3a3","query":{"term":{"content":"new"}}}},{"function_score":{"boost":10000000,"query":{"term":{"fileName":{"_name":"fileName_new","value":"new"}}}}}]}},{"bool":{"should":[{"codesearch_score_query":{"query_id":"9baec4c4-d910-4023-899e-5a580bfbd3a3","query":{"term":{"content":"version"}}}},{"function_score":{"boost":10000000,"query":{"term":{"fileName":{"_name":"fileName_version","value":"version"}}}}}]}},{"bool":{"should":[{"codesearch_score_query":{"query_id":"9baec4c4-d910-4023-899e-5a580bfbd3a3","query":{"term":{"content":"and"}}}},{"function_score":{"boost":10000000,"query":{"term":{"fileName":{"_name":"fileName_and","value":"and"}}}}}]}},{"bool":{"should":[{"codesearch_score_query":{"query_id":"9baec4c4-d910-4023-899e-5a580bfbd3a3","query":{"term":{"content":"install"}}}},{"function_score":{"boost":10000000,"query":{"term":{"fileName":{"_name":"fileName_install","value":"install"}}}}}]}},{"bool":{"should":[{"codesearch_score_query":{"query_id":"9baec4c4-d910-4023-899e-5a580bfbd3a3","query":{"term":{"content":"previous"}}}},{"function_score":{"boost":10000000,"query":{"term":{"fileName":{"_name":"fileName_previous","value":"previous"}}}}}]}},{"bool":{"should":

and regex:

grok {
			match => { "[Query_body]" => "(?<=fileName)(?<body>.*)"}
        }


It matching many times but i need only first group. How i can to do this? If it possible.
Sorry for my English.

If you just want the "copy" from filename_copy then you could use

grok { match => { "message" => '(?<=fileName_)(?<body>.+?)"' } }

Hi, thanks for response.
With this pattern i have many matches like on screenshot.
I need take only first or concatenate all matches to array like
[
"1 value",
"2 value",
...
etc
]

Can someone help with my problem? Or it impossible in standard Logstash config?

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