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!

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 ...