Splunk Enterprise Security

Is there a way to modify an inputlookup subsearch from an implied equals operator to an "IN" operator?

cogden
Engager

I have a subsearch doing "| inputlookup" against a CSV... the implied operator is equals. "Column/Field = Cell Value" ... is anybody aware of a way to overload or modify that operator from equals to IN. For example, if my cell value is a comma-separated list value1,value2 I dont want the search to be field="value1,value2" I would want the search to be field IN (value1,value2)

Example search:
|tstats count WHERE [inputlookup test.csv]

Example: test.csv:
mycolumn
value1,value2

Desired expanded search:
|tstats count WHERE mycolumn IN (value1,value2)

Actual expanded search:
| tstats count WHERE mycolumn="value1,value2"

0 Karma

woodcock
Esteemed Legend

Use this macro:

[convert_search_from_ORs_to_IN]
definition = rename COMMENT AS "EXTREME WARNING!!! THIS IS ONLY VALID IF YOU ARE USING A SINGLE FIELD!!!!"\
| rex field=search mode=sed "s/^\(\s*\(\s*// s/\s*\)\s*\)$/)/ s/=/ IN(/ s/\s*\)\s*OR\s*\([^=]+=/,/g"
errormsg = Description: Author=Gregg Woodcock; this is necessary because if the number of characters in a search string is too great, the search may fail; this conversion saves ~50%!
iseval = 0

Then, any place where you are doing something like this:

index=foo [|inputlookup tableOfHosts | table host]

Change it to this:

index=foo [|inputlookup tableOfHosts | table host | `convert_search_from_ORs_to_IN`]
0 Karma

cogden
Engager

SOLVED INTERNALLY:

Adding to the subsearch an eval split based on comma followed by an mvexpand accomplishes a similar result:

Example:

|tstats count WHERE [ | inputlookup test.csv | eval mycolumn = split(mycolumn,",") | mvexpand mycolumn ]

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.


Introducing Unified TDIR with the New Enterprise Security 8.2

Read the blog

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...