<?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: results into a single row table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/results-into-a-single-row-table/m-p/37643#M8454</link>
    <description>&lt;P&gt;Seeing the example searches and data would be useful indeed.  Without them, though, we can still do some handwaving toward an answer.  This may not be correct, depending on your exact searches, but it should get you in the ballpark.&lt;/P&gt;

&lt;P&gt;Let's start by putting all three of your searches together.  This is far from the most efficient way, but it's what works with all I have to go on:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search1 | append [ search search2 ] | append [ search search3]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;append&lt;/CODE&gt; search command will run each of these three searches and append their results together.  The additional word &lt;CODE&gt;search&lt;/CODE&gt; in the subsearches for search2/search3 is required as part of the subsearch.&lt;/P&gt;

&lt;P&gt;Now, I'll make an assumption that "search1" returns an extracted field named "up", "search2" returns extracted fields named "failed" and "success", and "search3" returns an extracted field named "down".  I'll also assume that the field names "up", "failed", "success", and "down" are unique and exclusive to their respective searches.  (That is, "search1" does NOT have an extracted field named "failed", "success", or "down" ... and so on)&lt;/P&gt;

&lt;P&gt;Given the above assumptions, we know that the &lt;CODE&gt;stats&lt;/CODE&gt; operation &lt;CODE&gt;max()&lt;/CODE&gt; should only find a single value to be "the" maximum for a given field.  So, we can use stats to collapse this into a single table row:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... (above search) ... 
| stats max(up) as up, max(failed) as failed, max(success) as success, max(down) as down
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Giving you a single table row for results from all three searches ...&lt;/P&gt;</description>
    <pubDate>Thu, 16 Aug 2012 23:45:55 GMT</pubDate>
    <dc:creator>dwaddle</dc:creator>
    <dc:date>2012-08-16T23:45:55Z</dc:date>
    <item>
      <title>results into a single row table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/results-into-a-single-row-table/m-p/37641#M8452</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have three search results giving me three different set of results, there are values from each search. I have not been able to find a way to get the results into a single row table.&lt;/P&gt;

&lt;P&gt;I need merge all these result into a single row in a single table.&lt;/P&gt;

&lt;P&gt;The structure of the search I have used is given below. &lt;/P&gt;

&lt;P&gt;[ search 1 ] &lt;/P&gt;

&lt;P&gt;[ search 2 ] &lt;/P&gt;

&lt;P&gt;[ search 3 ] &lt;/P&gt;

&lt;P&gt;the resulting table should look like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; up             failed                  success            down
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;results search1   results search2      results search2     results search3&lt;/P&gt;

&lt;P&gt;Appreciate any help!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2012 20:30:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/results-into-a-single-row-table/m-p/37641#M8452</guid>
      <dc:creator>fresned</dc:creator>
      <dc:date>2012-08-16T20:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: results into a single row table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/results-into-a-single-row-table/m-p/37642#M8453</link>
      <description>&lt;P&gt;Can you post the searches?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2012 21:21:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/results-into-a-single-row-table/m-p/37642#M8453</guid>
      <dc:creator>tfletcher_splun</dc:creator>
      <dc:date>2012-08-16T21:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: results into a single row table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/results-into-a-single-row-table/m-p/37643#M8454</link>
      <description>&lt;P&gt;Seeing the example searches and data would be useful indeed.  Without them, though, we can still do some handwaving toward an answer.  This may not be correct, depending on your exact searches, but it should get you in the ballpark.&lt;/P&gt;

&lt;P&gt;Let's start by putting all three of your searches together.  This is far from the most efficient way, but it's what works with all I have to go on:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search1 | append [ search search2 ] | append [ search search3]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;append&lt;/CODE&gt; search command will run each of these three searches and append their results together.  The additional word &lt;CODE&gt;search&lt;/CODE&gt; in the subsearches for search2/search3 is required as part of the subsearch.&lt;/P&gt;

&lt;P&gt;Now, I'll make an assumption that "search1" returns an extracted field named "up", "search2" returns extracted fields named "failed" and "success", and "search3" returns an extracted field named "down".  I'll also assume that the field names "up", "failed", "success", and "down" are unique and exclusive to their respective searches.  (That is, "search1" does NOT have an extracted field named "failed", "success", or "down" ... and so on)&lt;/P&gt;

&lt;P&gt;Given the above assumptions, we know that the &lt;CODE&gt;stats&lt;/CODE&gt; operation &lt;CODE&gt;max()&lt;/CODE&gt; should only find a single value to be "the" maximum for a given field.  So, we can use stats to collapse this into a single table row:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... (above search) ... 
| stats max(up) as up, max(failed) as failed, max(success) as success, max(down) as down
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Giving you a single table row for results from all three searches ...&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2012 23:45:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/results-into-a-single-row-table/m-p/37643#M8454</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2012-08-16T23:45:55Z</dc:date>
    </item>
  </channel>
</rss>

