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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...