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!

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Dashboard Challenge and Watch the .conf24 Global Broadcast!

The Splunk Community Dashboard Challenge is still happening, and it's not too late to enter for the week of ...