Splunk Search

Extract multiple groups (rex), key/value pairs comma separated

ejwade
Contributor

I'm looking for the regular expression wizards out there. I need to do a rex with two capture groups: one for name, and one for value. I plan to use the replace function, and throw everything else away but those two capture groups (e.g., "\1: \2").

Here are some sample events.

name="Building",value="Southwest",descendants_action="success",operation="OVERRIDE"
name="Building",value=["Northeast","Northwest"],descendants_action="failure",operation="OVERRIDE"
name="Building",value="Southeast",descendants_action="success",operation="OVERRIDE"
name="Building",value="Northwest"
name="Building",value="Northwest",operation="OVERRIDE"

So far I just have this.
^name=\"(.*)\",value=\[?(.*)\]?

Any ideas?

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try something along these lines

^name=\"([^\"]*)\",value=(\[([^\]]+)\]|\"[^\"]+\")(.*)

https://regex101.com/r/id6m8s/1

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Try something along these lines

^name=\"([^\"]*)\",value=(\[([^\]]+)\]|\"[^\"]+\")(.*)

https://regex101.com/r/id6m8s/1

gcusello
SplunkTrust
SplunkTrust

Hi @ejwade,

you should already have these extractions because usually Splunk identifies the groups fieldname=fieldvalue.

Anyway, please try this regex:

name\=\"(?<name>[^\"]*)\",value\=\[*\"(?<values>[^\"]*)

that you can test at https://regex101.com/r/PEszES/1

Ciao.

Giuseppe

Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...