<?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: Combining searches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191634#M187207</link>
    <description>&lt;P&gt;You can, and did... about six times &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I won't be available for the next few weeks, you can talk to the sales people listed on my website though.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Aug 2014 16:34:13 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-08-25T16:34:13Z</dc:date>
    <item>
      <title>Combining searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191626#M187199</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I want to combine some search results. I have one base search from there I need to do several searches, but at the end I need a single search result. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my base search | search code="1" ..do something

my base search | search code="2" ..do the same

my base search | search code="3" ..do also the same
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There is always the same thing to do, but I need to separate the searches for calculating the time between events with the same code. Is it possible to do this in a single search, because there are 250 different codes. Something like: &lt;CODE&gt;my base search | for every value of code do this&lt;/CODE&gt; At the end I need a table with all codes in it.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 09:23:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191626#M187199</guid>
      <dc:creator>TBo123</dc:creator>
      <dc:date>2014-08-22T09:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Combining searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191627#M187200</link>
      <description>&lt;P&gt;Do post what you're doing with each code.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 10:03:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191627#M187200</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-08-22T10:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Combining searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191628#M187201</link>
      <description>&lt;P&gt;You really don't provide any details on what you're trying to achieve so it's hard to give really useful advice, but you could look into the &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.3/SearchReference/Map"&gt;&lt;CODE&gt;map&lt;/CODE&gt;&lt;/A&gt; command which does something similar to what you're describing.&lt;/P&gt;

&lt;P&gt;That said, it's highly likely you could find an even better solution that doesn't involve looping searches like this. If you described your exact problem, your data, your searches more chances are we can help you out with finding alternate solutions.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 10:07:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191628#M187201</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2014-08-22T10:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Combining searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191629#M187202</link>
      <description>&lt;P&gt;In my base search I calculate the code and group events which occur within some milliseconds. They will get the same ID. The next step is to look after events that have the same code and got wrong IDs in the first step, because they occur within some seconds, they should also get the same ID. I implement such a search for one code in that way:&lt;/P&gt;

&lt;P&gt;first step, my base search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=Host_MA  SEVERITY != FATAL  | eval Zusatz=case(match(_raw,"VOLTAGE"),"VOLT",                   match(_raw,"TEMPERATURE"),"TEMP", match(_raw,"CURRENT"),"CURR", match(_raw,"power module fault"),"POMF")               | eval Zusatz=if(Zusatz!="",Zusatz,"NULL") | eval Code=MSG_ID + ";" + Subcomponent + ";"  + SEVERITY + ";" + Zusatz| delta _time p=1 AS diff | eval diff=round(-diff,3) | streamstats current=f window=1 first(Code) as prevcode | eval ID=case(isnull(diff),1,diff&amp;gt;0.003,1,1=1,0) | accum ID |
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;second step, several search with one code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search Code="KERN_2205;bg_subcomp_linux;WARN;NULL" | delta _time p=1 AS diff2 | eval diff2=round(-diff2,3) | eval ID2=case(isnull(diff2),1,diff2&amp;gt;1.0,1,1=1,0) | accum ID2 | eventstats first(ID) as temp_id1 by ID2 | fields - ID, ID2, diff2| rename temp_id1 as ID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After that search I only get events with Code="KERN_2205;bg_subcomp_linux;WARN;NULL" but I look for a way to add the results of the next search with code="..." but there are over 250 different codes, perhaps there is an easier way?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:23:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191629#M187202</guid>
      <dc:creator>TBo123</dc:creator>
      <dc:date>2020-09-28T17:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Combining searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191630#M187203</link>
      <description>&lt;P&gt;that is what I have to do with every code: search Code="KERN_2205;bg_subcomp_linux;WARN;NULL" | delta _time p=1 AS diff2 | eval diff2=round(-diff2,3) | eval ID2=case(isnull(diff2),1,diff2&amp;gt;1.0,1,1=1,0) | accum ID2 | eventstats first(ID) as temp_id1 by ID2 | fields - ID, ID2, diff2| rename temp_id1 as ID&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:23:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191630#M187203</guid>
      <dc:creator>TBo123</dc:creator>
      <dc:date>2020-09-28T17:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Combining searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191631#M187204</link>
      <description>&lt;P&gt;I tried map but I got no results?! map search="search mycode=$code$ and the rest of my search"&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 11:06:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191631#M187204</guid>
      <dc:creator>TBo123</dc:creator>
      <dc:date>2014-08-22T11:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Combining searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191632#M187205</link>
      <description>&lt;P&gt;I'm not quite sure what your overall goal is, but here's how you can replace commands you've used in your comment to work for all codes in one go.&lt;/P&gt;

&lt;HR /&gt;

&lt;PRE&gt;&lt;CODE&gt;... | delta _time p=1 AS diff2 | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You search for one code because &lt;CODE&gt;delta&lt;/CODE&gt; doesn't have a group-by option... however, you can just use &lt;CODE&gt;streamstats&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | streamstats window=1 current=f global=f last(_time) as previous by Code | eval diff2 = previous - _time | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That'll copy over the neighbouring timestamp &lt;EM&gt;for each value of Code&lt;/EM&gt;, effectively computing a &lt;CODE&gt;diff _time by Code&lt;/CODE&gt;.&lt;/P&gt;

&lt;HR /&gt;

&lt;PRE&gt;&lt;CODE&gt;... | accum ID2 | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Same thing here, use &lt;CODE&gt;streamstats&lt;/CODE&gt; with a grouping field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | streamstats sum(ID2) as sum_ID2 by Code | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eventstats first(ID) as temp_id1 by ID2 | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is easiest, just add &lt;CODE&gt;Code&lt;/CODE&gt; to the grouping:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eventstats first(ID) as temp_id1 by ID2 Code | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;Disclaimer: I'm just going by the search you posted, not the use case behind it. Some transformations may not work in 100% of all imaginable cases, so do test what I posted thoroughly.&lt;/P&gt;

&lt;P&gt;Finally, if you need on-site German-speaking help... &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 11:42:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191632#M187205</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-08-22T11:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: Combining searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191633#M187206</link>
      <description>&lt;P&gt;Thank you very much. That's just the ticket for me. How can I contact you for German-speaking help? I can't send you a mail?!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Aug 2014 10:18:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191633#M187206</guid>
      <dc:creator>TBo123</dc:creator>
      <dc:date>2014-08-25T10:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Combining searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191634#M187207</link>
      <description>&lt;P&gt;You can, and did... about six times &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I won't be available for the next few weeks, you can talk to the sales people listed on my website though.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Aug 2014 16:34:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-searches/m-p/191634#M187207</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-08-25T16:34:13Z</dc:date>
    </item>
  </channel>
</rss>

