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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...