Splunk Enterprise Security

How to separate field values from a single field into two unique values?

Splunkuser542
Explorer

Hi,

Using the following event log which has not been extracted, is it possible to seperate the current 'Name:' field to two seperate fields so that I can table the two unique values? For example, the first 'Name:' field renamed to 'To:' and the second 'Name:' field renamed to 'From:'.

--- To Details --- 
Name: John Smith
...
...

--- From Details --- 
Name: Bob Marley
...
...

End result:

To         | From
John Smith | Bob Marley
1 Solution

niketn
Legend

@Splunkuser542 , as you might be aware this kind of regular expression extraction depends on pattern before and after the required field value to be extracted. So unless this kind of pattern is not present or explained in your question/sample data, our suggestion might not work for you. Add the following to your search to see if it works:

  <yourCurrentSearch>
 | rex "--- To Details ---\s+Name:\s(?<ToName>.+)"
 | rex "--- From Details ---\s+Name:\s(?<FromName>.+)"

Following is a run anywhere example based on your sample data provided in the question.

| makeresults
| eval _raw=" --- To Details --- 
 Name: John Smith
 ...
 ...

 --- From Details --- 
 Name: Bob Marley
 ...
 ..."
 | rex "--- To Details ---\s+Name:\s(?<ToName>.+)"
 | rex "--- From Details ---\s+Name:\s(?<FromName>.+)"
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

@Splunkuser542 , as you might be aware this kind of regular expression extraction depends on pattern before and after the required field value to be extracted. So unless this kind of pattern is not present or explained in your question/sample data, our suggestion might not work for you. Add the following to your search to see if it works:

  <yourCurrentSearch>
 | rex "--- To Details ---\s+Name:\s(?<ToName>.+)"
 | rex "--- From Details ---\s+Name:\s(?<FromName>.+)"

Following is a run anywhere example based on your sample data provided in the question.

| makeresults
| eval _raw=" --- To Details --- 
 Name: John Smith
 ...
 ...

 --- From Details --- 
 Name: Bob Marley
 ...
 ..."
 | rex "--- To Details ---\s+Name:\s(?<ToName>.+)"
 | rex "--- From Details ---\s+Name:\s(?<FromName>.+)"
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

Splunkuser542
Explorer

Thanks @niketnilay - the first solution worked.

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

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

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...