<?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: Lookup against Splunk Search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Lookup-against-Splunk-Search/m-p/193740#M55838</link>
    <description>&lt;P&gt;I was able to achieve the necessary results using the map command, then joining back on the initial search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest="-24h@h" latest="now" index=foo sourcetype=mysrc state=7 type!=9
| join type=outer usetime=True id [ search 
  index=foo sourcetype=mysrc state=7 type!=9
  | map maxsearches=500 search=" search
    index=bar sourcetype=othersrc … id = $id$
    | eval count=$count$
    | evals and such …
    | eval number=somenumber*othernumber
    | stats sum(number) as sum_number values(id) as id" ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 05 Nov 2014 17:20:44 GMT</pubDate>
    <dc:creator>rizzo75</dc:creator>
    <dc:date>2014-11-05T17:20:44Z</dc:date>
    <item>
      <title>Lookup against Splunk Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-against-Splunk-Search/m-p/193736#M55834</link>
      <description>&lt;P&gt;I need to run a search, then run another search to calculate a specific value.  Almost like a lookup with splunk commands.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search ... | fields id count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;for each event run: search ... id=$id$ | eval count=$count$ | ... calculations ... | stats sum(n) as N&lt;/P&gt;

&lt;P&gt;The output would have all values:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id    | count | N
------------------------
111 | 222     | 333
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What is the best way to achieve this?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Tue, 04 Nov 2014 16:41:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-against-Splunk-Search/m-p/193736#M55834</guid>
      <dc:creator>rizzo75</dc:creator>
      <dc:date>2014-11-04T16:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup against Splunk Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-against-Splunk-Search/m-p/193737#M55835</link>
      <description>&lt;P&gt;provide some sample events and expected result&lt;BR /&gt;
If possible provide the search query you are running.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Nov 2014 17:04:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-against-Splunk-Search/m-p/193737#M55835</guid>
      <dc:creator>vasanthmss</dc:creator>
      <dc:date>2014-11-04T17:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup against Splunk Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-against-Splunk-Search/m-p/193738#M55836</link>
      <description>&lt;P&gt;Have a look on the &lt;CODE&gt;map&lt;/CODE&gt; command... Provide some additional event data and expected results as vasanthmss mentioned to help writing the search.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Nov 2014 21:35:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-against-Splunk-Search/m-p/193738#M55836</guid>
      <dc:creator>musskopf</dc:creator>
      <dc:date>2014-11-04T21:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup against Splunk Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-against-Splunk-Search/m-p/193739#M55837</link>
      <description>&lt;P&gt;Using your example, you could do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | map maxsearches=42 [search ... id=$id$ | eval count = $count$ | ... calculations ... | stats sum(n) as N]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That'll give you up to 42 rows with a column &lt;CODE&gt;N&lt;/CODE&gt; containing the sum. Depending on your calculations, it might be a &lt;STRONG&gt;lot&lt;/STRONG&gt; faster to do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | ... calculations, possibly involving some "by id" ... | stats sum(n) as N by id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Nov 2014 22:57:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-against-Splunk-Search/m-p/193739#M55837</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-11-04T22:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup against Splunk Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Lookup-against-Splunk-Search/m-p/193740#M55838</link>
      <description>&lt;P&gt;I was able to achieve the necessary results using the map command, then joining back on the initial search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest="-24h@h" latest="now" index=foo sourcetype=mysrc state=7 type!=9
| join type=outer usetime=True id [ search 
  index=foo sourcetype=mysrc state=7 type!=9
  | map maxsearches=500 search=" search
    index=bar sourcetype=othersrc … id = $id$
    | eval count=$count$
    | evals and such …
    | eval number=somenumber*othernumber
    | stats sum(number) as sum_number values(id) as id" ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Nov 2014 17:20:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Lookup-against-Splunk-Search/m-p/193740#M55838</guid>
      <dc:creator>rizzo75</dc:creator>
      <dc:date>2014-11-05T17:20:44Z</dc:date>
    </item>
  </channel>
</rss>

