<?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: 2 searches, 1 csv in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/2-searches-1-csv/m-p/86887#M22187</link>
    <description>&lt;P&gt;Since they are over the same time range, append would work.  If you find there are more than 1 value for each status and count (ex. 13 and 402 for countA with status 500) you can replace values() with max() or latest().&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;host="server01" OR host="server03" source="/opt/httpd/logs/access_log"  | stats count by status | rename count AS countA | append[ search host="server13" OR host="server14" source="/data/logs/apache/access_log" | stats count by status | rename count AS countB ] | stats values(countA) as countA values(countB) as countB by status&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Jan 2013 21:08:24 GMT</pubDate>
    <dc:creator>alacercogitatus</dc:creator>
    <dc:date>2013-01-14T21:08:24Z</dc:date>
    <item>
      <title>2 searches, 1 csv</title>
      <link>https://community.splunk.com/t5/Splunk-Search/2-searches-1-csv/m-p/86886#M22186</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;I have searched around, but I haven't found an example that has shown me the way.&lt;/P&gt;

&lt;P&gt;What I am trying to do is a search on one location, and compare the stats with another location. &lt;/P&gt;

&lt;P&gt;Here are the two searches: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="server01" OR host="server03" source="/opt/httpd/logs/access_log"  | stats count by status | rename count AS countA
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="server13" OR host="server14" source="/data/logs/apache/access_log" | stats count by status | rename count AS countB
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to output this information to a csv file that would look like this, using the static error code as one column, and then the variables countA and countB:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status,countA,countB
200,563805,6345
206,10,1345
301,33529,345
302,84470,673468
304,1747,46
400,42,23
403,36,346
404,25,46
500,29,45
502,2,345
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The best that I was able to do was to get them all into the file, with duplicate entries for the status codes...&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2013 21:00:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/2-searches-1-csv/m-p/86886#M22186</guid>
      <dc:creator>casspugh</dc:creator>
      <dc:date>2013-01-14T21:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: 2 searches, 1 csv</title>
      <link>https://community.splunk.com/t5/Splunk-Search/2-searches-1-csv/m-p/86887#M22187</link>
      <description>&lt;P&gt;Since they are over the same time range, append would work.  If you find there are more than 1 value for each status and count (ex. 13 and 402 for countA with status 500) you can replace values() with max() or latest().&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;host="server01" OR host="server03" source="/opt/httpd/logs/access_log"  | stats count by status | rename count AS countA | append[ search host="server13" OR host="server14" source="/data/logs/apache/access_log" | stats count by status | rename count AS countB ] | stats values(countA) as countA values(countB) as countB by status&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2013 21:08:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/2-searches-1-csv/m-p/86887#M22187</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2013-01-14T21:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: 2 searches, 1 csv</title>
      <link>https://community.splunk.com/t5/Splunk-Search/2-searches-1-csv/m-p/86888#M22188</link>
      <description>&lt;P&gt;OK -  this post helped me.  &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answers/51740/comparing-results-from-two-searches/62359"&gt;http://splunk-base.splunk.com/answers/51740/comparing-results-from-two-searches/62359&lt;/A&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I was able to use this search to obtain the result I wanted.  It takes about 45s to run though, so if anyone has a better idea, I am all ears!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="server01" OR host="server03" source="/opt/httpd/logs/access_log"  | stats count by status | rename count AS countA | appendcols [ search ( host="server13" OR host="server14" source="/data/logs/apache/access_log"  )| stats count by status | rename count AS countB ] | outputcsv combinedstats.csv
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Jan 2013 21:13:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/2-searches-1-csv/m-p/86888#M22188</guid>
      <dc:creator>casspugh</dc:creator>
      <dc:date>2013-01-14T21:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: 2 searches, 1 csv</title>
      <link>https://community.splunk.com/t5/Splunk-Search/2-searches-1-csv/m-p/86889#M22189</link>
      <description>&lt;P&gt;Thanks!  This does work too!  I will compare the two searches to see if there are any differences!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2013 21:18:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/2-searches-1-csv/m-p/86889#M22189</guid>
      <dc:creator>casspugh</dc:creator>
      <dc:date>2013-01-14T21:18:00Z</dc:date>
    </item>
  </channel>
</rss>

