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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...