Splunk Search

regex in lookup file

ankitarath2011
Path Finder

I want to match a reg ex pattern (e.g. "aaa\s+:\d\d") from a lookup file.

pattern,output_value
"aaa\s+:\d\d:", 2
"aaa\s+:\d:", 1

So, whenever first pattern matches in the event, I should get value as 2.
How can we do this?

Tags (2)
0 Karma

mhoogcarspel_sp
Splunk Employee
Splunk Employee

Build a subsearch to build the EVALs for you?

| makeresults 
| eval _raw="aaa :4:" 
| eval 
    [| inputlookup test_regex.csv 
    | fields pattern output_value 
    | eval search="test=if(match(_raw,\"".pattern."\"),\"".output_value."\", test), " 
    | fields search 
    | mvcombine search 
    | eval search=trim(trim(mvjoin(search," "),"| eval"),", ")]
0 Karma

ankitarath2011
Path Finder

Hey getting below error

Error in 'eval' command: The expression is malformed. An unexpected character is reached at ')'.

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...