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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...