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!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...