Splunk Search

Extract multiple words in a filed

marco_massari11
Communicator

Hi,

I have some syslog logs and I need to extract the first words of a field values. The field value starts like this:

Site Corporate Windows AM\\Passed\\     

My result should be :       

Corporate Passed

Note: I can have also Unmanaged instead of Corporate and Failed insted of Passed, so I have 4 options:

Corporate Passed

Corporate Failed

Unmanaged Passed

Unmanaged Failed         

Labels (4)
0 Karma
1 Solution

nickhills
Ultra Champion

That happens because of some additional escaping which is needed.

 

Try this version, which avoids needing a triple \ 

 

Site (?<site>\w+).+\\\\(?<result>\w+)

 

If my comment helps, please give it a thumbs up!

View solution in original post

0 Karma

493669
Super Champion

@marco_massari11 if you want extract multiple fields then try below-
Updated-

 

Site (?<field1>\w+)[^\\\\]+\\\\(?<field2>\w+)

 

It will extract in field1 and field2.



-------
let me know if it helps! 

0 Karma

marco_massari11
Communicator

Hi @493669  I have this message error  Regex: missing terminating ] for character class. 

0 Karma

nickhills
Ultra Champion

That happens because of some additional escaping which is needed.

 

Try this version, which avoids needing a triple \ 

 

Site (?<site>\w+).+\\\\(?<result>\w+)

 

If my comment helps, please give it a thumbs up!
0 Karma
Get Updates on the Splunk Community!

Streamline Data Ingestion With Deployment Server Essentials

REGISTER NOW!Every day the list of sources Admins are responsible for gets bigger and bigger, often making the ...

Remediate Threats Faster and Simplify Investigations With Splunk Enterprise Security ...

REGISTER NOW!Join us for a Tech Talk around our latest release of Splunk Enterprise Security 7.2! We’ll walk ...

Introduction to Splunk AI

WATCH NOWHow are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. ...