Splunk Search

How can I search events based on another lookup file subsearch using like.

JMPP
Explorer

Hi,

Would you mind to help on this?, I have been working for days to figure out how can I pass a lookup file subsearch as "like" condition in main search, something like:

To examples:
1) 

. . main search| where like(onerowevent, "%".[search [| inputlookup blabla.csv| <whatever_condition_to_make_onecompare_field>|table onecompare }]."%"]])



2)

. . main search| eval  onerowevent=if(like(onerowevent,, "%".[search [| inputlookup blabla.csv| <whatever_condition_to_make_onecompare_field>|table onecompare }]."%"]])),onerowevent,"")
Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

By default, a subsearch returns its results as a formatted string.  Run the subsearch by itself with | format appended to see what it looks like.

A workaround may be to use the return command instead of table.

 main search| eval  onerowevent=if(like(onerowevent,, "%".[search [| inputlookup blabla.csv| <whatever_condition_to_make_onecompare_field>|return $onecompare }]."%"]])),onerowevent,"")
---
If this reply helps you, Karma would be appreciated.

View solution in original post

JMPP
Explorer

Hi @richgalloway 

Your sugestion to use return helped me to make the query works. I have made to make some adjustments too :

..main search |where like(onerowevent, [| inputlookup blabla.csv| <whatever_condition_to_make_onecompare_field>| eval onecompare="\"%".onecompare."%\""|return $onecompare]

The only thing is, when I'm using '   |return $onecompare  ', I'm missing one row from the output, even if I test the subsearch separately.

I will figure out what is making ' return ' clause skip the row.

Regards,

0 Karma

richgalloway
SplunkTrust
SplunkTrust

By default, the return command returns only the first value of the specified fields.  Use return n to return n number of values.

---
If this reply helps you, Karma would be appreciated.
0 Karma

richgalloway
SplunkTrust
SplunkTrust

By default, a subsearch returns its results as a formatted string.  Run the subsearch by itself with | format appended to see what it looks like.

A workaround may be to use the return command instead of table.

 main search| eval  onerowevent=if(like(onerowevent,, "%".[search [| inputlookup blabla.csv| <whatever_condition_to_make_onecompare_field>|return $onecompare }]."%"]])),onerowevent,"")
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...