Splunk Search

RegEx Extraction Assistance for new field.

matt4321
Explorer

I have a field that looks like the below.

PM=Rodhouse,Logan (PM Build VZT-PM)
PM=Allen,Jim (PM Run-PM)

Basically breaksdown like the below.
PM= Last,First Name (PM "Group"-PM)

I would like to create a custom field for the Any Text that is in the "Group" Part.
PMGroup="Group"

PMGroup=Build VZT
PMGroup=Run

Any help would be appreciated.

Tags (2)
0 Karma
1 Solution

niketn
Legend

Try the following rex command

<YourBaseSearch>
|  rex "\(PM\s(?<PMGroup>[^\-]+)\-PM\)"

You can create a Field Extraction with the same regular expression once you have tested with your sample data. You can also use regex101.com for understanding how this regex is working.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

Try the following rex command

<YourBaseSearch>
|  rex "\(PM\s(?<PMGroup>[^\-]+)\-PM\)"

You can create a Field Extraction with the same regular expression once you have tested with your sample data. You can also use regex101.com for understanding how this regex is working.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

matt4321
Explorer

This worked perfect but for some reason I had to add field=PM for it to extract properly.

| rex field=PM "\(PM\s(?<PMGroup>[^\-]+)\-PM\)"

niketn
Legend

Ok my query was for raw data so it should have also worked, but field=PM would work as well. Eventually create a field extraction with regex using Interactive Field Extraction or props.conf/transforms.conf whichever you are comfortable with.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...