<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using lookup values as input for query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-lookup-values-as-input-for-query/m-p/262389#M78772</link>
    <description>&lt;P&gt;as mentioned in some answers below, I like using subsearches for this sort of thing.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Jul 2016 15:50:29 GMT</pubDate>
    <dc:creator>muebel</dc:creator>
    <dc:date>2016-07-15T15:50:29Z</dc:date>
    <item>
      <title>Using lookup values as input for query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-lookup-values-as-input-for-query/m-p/262385#M78768</link>
      <description>&lt;P&gt;Hi all, &lt;/P&gt;

&lt;P&gt;so I built this query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; search index=sey_ips src_ip=10.0.0.1 dest_ip=10.0.0.2
| eval time = _time
| sort - time
| streamstats current=f window=1 first(time) AS lastTime by src_ip, dest_ip, signature_id
| eval diff = lastTime-time
| search lastTime=*
| table _time, src_ip, dest_ip, time, lastTime, signature_id, diff
| stats stdev(diff) by src_ip, dest_ip, signature_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I define the IPs manually it works great, but I have a lookup file containing quite a lot of src_ip, dest_ip combination and I'd like to run this query with all the defined IPs. How would I do that? I am basically looking for something like a loop.&lt;/P&gt;

&lt;P&gt;Thank you &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:15:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-lookup-values-as-input-for-query/m-p/262385#M78768</guid>
      <dc:creator>pinVie</dc:creator>
      <dc:date>2020-09-29T10:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using lookup values as input for query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-lookup-values-as-input-for-query/m-p/262386#M78769</link>
      <description>&lt;P&gt;Use double quotes on the border of IP.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2016 15:11:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-lookup-values-as-input-for-query/m-p/262386#M78769</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-07-15T15:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using lookup values as input for query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-lookup-values-as-input-for-query/m-p/262387#M78770</link>
      <description>&lt;P&gt;You can work the loop a bit backwards using subsearches:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index=sey_ips [|inputlookup ip_lookup.csv| fields src_ip, dst_ip | return 0 src_ip dst_ip] 
 | eval time = _time
 | sort - time
 | streamstats current=f window=1 first(time) AS lastTime by src_ip, dest_ip, signature_id
 | eval diff = lastTime-time
 | search lastTime=*
 | table _time, src_ip, dest_ip, time, lastTime, signature_id, diff
 | stats stdev(diff) by src_ip, dest_ip, signature_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Youll end up with a final search like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; search index=sey_ips (src_ip=10.0.0.1 OR src_ip=10.0.0.2 OR src_ip=10.0.0.3) OR (dst_ip=10.1.0.1 OR dst_ip=10.2.0.2 OR dst_ip=10.3.0.3) | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To change this so that there is an AND instead of OR between the src_ips and dst_ips... you need to use format instead of return:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index=sey_ips [|inputlookup ip_lookup.csv| fields src_ip, dst_ip |format "(" "(" "OR" ")" "AND" ")"]
 | eval time = _time
 | sort - time
 | streamstats current=f window=1 first(time) AS lastTime by src_ip, dest_ip, signature_id
 | eval diff = lastTime-time
 | search lastTime=*
 | table _time, src_ip, dest_ip, time, lastTime, signature_id, diff
 | stats stdev(diff) by src_ip, dest_ip, signature_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/Format" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/Format&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/Return" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/Return&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/SearchTutorial/Useasubsearch" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.2/SearchTutorial/Useasubsearch&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.4.1/Search/Changetheformatofsubsearchresults" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/6.4.1/Search/Changetheformatofsubsearchresults&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:14:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-lookup-values-as-input-for-query/m-p/262387#M78770</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2020-09-29T10:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using lookup values as input for query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-lookup-values-as-input-for-query/m-p/262388#M78771</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index=sey_ips [| inputlookup yourlookup.csv | table src_ip dest_ip]
 | eval time = _time
 | sort - time
 | streamstats current=f window=1 first(time) AS lastTime by src_ip, dest_ip, signature_id
 | eval diff = lastTime-time
 | search lastTime=*
 | table _time, src_ip, dest_ip, time, lastTime, signature_id, diff
 | stats stdev(diff) by src_ip, dest_ip, signature_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR (loop method, but try above one first)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup yourlookup.csv | table src_ip dest_ip | map maxsearches=1000 search="search index=sey_ips src_ip=$src_ip$ dest_ip=$dest_ip$
 | eval time = _time
 | sort - time
 | streamstats current=f window=1 first(time) AS lastTime by src_ip, dest_ip, signature_id
 | eval diff = lastTime-time
 | search lastTime=*
 | table _time, src_ip, dest_ip, time, lastTime, signature_id, diff
 | stats stdev(diff) by src_ip, dest_ip, signature_id"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Jul 2016 15:18:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-lookup-values-as-input-for-query/m-p/262388#M78771</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-07-15T15:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using lookup values as input for query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-lookup-values-as-input-for-query/m-p/262389#M78772</link>
      <description>&lt;P&gt;as mentioned in some answers below, I like using subsearches for this sort of thing.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2016 15:50:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-lookup-values-as-input-for-query/m-p/262389#M78772</guid>
      <dc:creator>muebel</dc:creator>
      <dc:date>2016-07-15T15:50:29Z</dc:date>
    </item>
  </channel>
</rss>

