Splunk Search

Automatically add ORs between IPs for Dashboard

CYBR_AH
Explorer

Hi Community,

Suppose I get a list of IPs once a week and I want to search all the indexes for these IPs. Is it possible to take a list of IPs, paste them into a field on a dashboard, click Submit to search all of the indexes (or maybe one or two from a dropdown) for any events? This includes Splunk automatically adding ORs between each IP.

Ideally, I want to copy and paste into a field, click submit and run the following query:

search index=* ( 10.0.0.1 OR 10.0.0.2 OR 10.0.0.3 )

Those results would be populated into a statistics table. Is there a more efficient way or is this even possible?

Tags (1)
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

If you put this in your macros.conf

[ORify(1)]
args = x
definition = replace("$x$", "\s+", " OR ")
iseval = 1

you can paste your space-separated list of IPs into a text field and run this search:

index=* ( `ORify($IP_token$)` )

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

If you put this in your macros.conf

[ORify(1)]
args = x
definition = replace("$x$", "\s+", " OR ")
iseval = 1

you can paste your space-separated list of IPs into a text field and run this search:

index=* ( `ORify($IP_token$)` )

woodcock
Esteemed Legend

You can paste into a IPs.csv file with a header line that says IP_Address, upload the file as a lookup table, then do something like this:

index=* [|inputcsv IP.csv | rename IP_Address AS query]
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...