<?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: Splunk: Return One or True from a search, use that result in another search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Return-One-or-True-from-a-search-use-that-result-in/m-p/572228#M199435</link>
    <description>&lt;P&gt;You could do some fancy joins or - god forbid - maps but I'd just do one search, then append results from the other one (making sure that column names overlap where needed - especially extracting RUNID from source) and then do some stats by RUNID.&lt;/P&gt;&lt;P&gt;That's the general idea.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Oct 2021 10:22:20 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2021-10-25T10:22:20Z</dc:date>
    <item>
      <title>Splunk: Return One or True from a search, use that result in another search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Return-One-or-True-from-a-search-use-that-result-in/m-p/572223#M199432</link>
      <description>&lt;P&gt;Dear Splunk community,&lt;/P&gt;&lt;P&gt;In Splunk, I am looking for logs that say "started with profile: [profile name]" and retrieve the profile name from found events. Then I want to use the profile name to look for other events (from a different source) and if one error or more are found, I would like to let it count as one found error, per platform.&lt;/P&gt;&lt;P&gt;To make things more clear I have the following search query (&lt;STRONG&gt;query one):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; index="myIndex" "started with profile" BD_L* | table _raw, platform, RUNID | eval Platform=case(searchmatch("LINUX"),"LINUX",searchmatch("AIX"),"AIX",searchmatch("DB2"),"DB2", searchmatch("SQL"),"SQL", searchmatch("WEBSPHERE"),"WEBSPHERE", searchmatch("SYBASE"),"SYBASE", searchmatch("WINDOWS"),"WINDOWS", true(),"ZLINUX") | stats count by Platform | rename count AS "Amount" &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The events found from above query contains the following (raw) :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; Discovery run, 2021101306351355 started with profile BD_L2_Windows &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above query will return a list of events containing the raw data above and will result in the following table. This is a table with the amount of Discovery runs per platform:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bleepie_0-1635156292395.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/16566i084D57CCC410A09A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Bleepie_0-1635156292395.png" alt="Bleepie_0-1635156292395.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Using the following piece of code I can extract RUNID from the events. RUNID is what I need to use in a second search when looking for errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; | rex "Discovery run, (?.+) started with profile" &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using RUNID I can look for errors (&lt;STRONG&gt;query two):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; index="myIndex" source="/*/RUNID/*" CASE("ERROR") CTJT* | dedup _raw | stats count | rename count AS "Amount" &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I am looking for a way to combine the above two queries into one and count the amount of platforms that have at least one error. So lets say we have the following simulation:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;- Two runs (one Windows and one Linux)&lt;/LI&gt;&lt;LI&gt;- Windows run has 0 errors (none found in query 2)&lt;/LI&gt;&lt;LI&gt;- Linux has 6 errors (found in query 2)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This should result in the following results:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Platform | Amount 
Linux    |      1 &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to find some way to return true&amp;nbsp;or one&amp;nbsp;from query 2 and use that in query 1 to group the results, but I am unable to due to lack of experience. I have not yet found anything similair to my question and hope anyone here can help me out. Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 10:10:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Return-One-or-True-from-a-search-use-that-result-in/m-p/572223#M199432</guid>
      <dc:creator>Bleepie</dc:creator>
      <dc:date>2021-10-25T10:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk: Return One or True from a search, use that result in another search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Return-One-or-True-from-a-search-use-that-result-in/m-p/572228#M199435</link>
      <description>&lt;P&gt;You could do some fancy joins or - god forbid - maps but I'd just do one search, then append results from the other one (making sure that column names overlap where needed - especially extracting RUNID from source) and then do some stats by RUNID.&lt;/P&gt;&lt;P&gt;That's the general idea.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 10:22:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Return-One-or-True-from-a-search-use-that-result-in/m-p/572228#M199435</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-10-25T10:22:20Z</dc:date>
    </item>
  </channel>
</rss>

