Splunk Search

How can I search a lookup table for rows that match an input string in any field?

matstap
Communicator

I need to search a lookup table for rows that match an input string in any field.

I've tried |inputlookup...... | search $searchKey$ but this returns no results.

How do I do this?

0 Karma
1 Solution

micahkemp
Champion

Try this:

| inputlookup <lookup>
| foreach * [eval matched=if(matched="YES" OR <<FIELD>>="searchkey", "YES", "NO")]
| search matched="YES"
| fields - matched

View solution in original post

micahkemp
Champion

Try this:

| inputlookup <lookup>
| foreach * [eval matched=if(matched="YES" OR <<FIELD>>="searchkey", "YES", "NO")]
| search matched="YES"
| fields - matched

matstap
Communicator

That's what I'm looking for. Thanks

0 Karma

micahkemp
Champion
| inputlookup <lookup name> WHERE <fieldname>=<value>

Your | search version would probably work if you did | search <fieldname>=<value>, but it's better to include the filter in inputlookup itself.

0 Karma

matstap
Communicator

Is there a way to do this without specifying the field? I just want to pass in a string x and if in one row FieldA=x and in another row FieldB=x, it will return both rows

0 Karma

micahkemp
Champion

I see I didn't really answer your question. I will revisit this in a few.

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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