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!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...