<?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: How to compare search results from 2 dates without using subsearch? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265969#M79957</link>
    <description>&lt;P&gt;Something along these lines. I took out your sort and head commands, as I wasn't sure how you'd want to cut off the values. :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=f5 instance=test earliest=-4d@d latest=-1d@d 
| eval urlall=split(uri,"?") 
| eval url=mvindex(urlall,0)+"*" 
| eval timeFrame=if(relative_time(now(),"-2d@d")&amp;gt;=_time,"old","new")
| chart count avg(reqtime) as avgtime by url timeFrame
| rename "count: old" as countold "count: new" as countnew "avgtime: old" as avgtimeold "avgtime: new" as avgtimenew
| where count&amp;gt;100 
| eval avgtimediff=avgtimenew-avgtimeold 
| eval avgtimediffpercent=tostring(floor(avgtimediff*100/avgtimeold))+"%" 
| eval countdiff=countnew-countold 
| eval countdiffpercent=tostring(floor(countdiff*100/countold))+"%" 
| table url,countold,countnew,countdiff,countdiffpercent,avgtimeold,avgtimenew,avgtimediff,avgtimediffpercent
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Oct 2016 18:09:33 GMT</pubDate>
    <dc:creator>cmerriman</dc:creator>
    <dc:date>2016-10-19T18:09:33Z</dc:date>
    <item>
      <title>How to compare search results from 2 dates without using subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265964#M79952</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm trying to compare stats from 2 different dates (sometimes not back to back)  and I'm running into a wall because of subsearch limitations.  I want to look at total count and average reqtime for grouped URLs for 2 different days and then find the difference between then.  Because of the number of logs, I would like to limit the search to just those days if possible.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=f5 instance=test earliest=-4d@d latest=-3d@d|eval urlall=split(uri,"?")|eval url=mvindex(urlall,0)+"*"|stats count avg(reqtime) as avgtimeold by url|sort - avgtimeold|where count&amp;gt;100|head 30|rename count as countold| join url [search index=f5 instance=test earliest=-2d@d latest=-1d@d|eval urlall=split(uri,"?")|eval url=mvindex(urlall,0)+"*"|stats count avg(reqtime) as avgtimenew by url|sort - avgtimenew|where count&amp;gt;100|head 100|rename count as countnew]|eval avgtimediff=avgtimenew-avgtimeold|eval avgtimediffpercent=tostring(floor(avgtimediff*100/avgtimeold))+"%"|eval countdiff=countnew-countold|eval countdiffpercent=tostring(floor(countdiff*100/countold))+"%"|table url,countold,countnew,countdiff,countdiffpercent,avgtimeold,avgtimenew,avgtimediff,avgtimediffpercent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The subsearch doesn't work because it takes longer than 60 seconds to return the results. I thought of using a lookup table, but the plan is to put this into a dashboard and I'm not sure how I could populate the lookup tables from there. If anyone has any suggestions on which way I could go, it would be greatly appreciated.  &lt;/P&gt;

&lt;P&gt;TIA!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 17:37:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265964#M79952</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2016-10-19T17:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare search results from 2 dates without using subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265965#M79953</link>
      <description>&lt;P&gt;are you on 6.5?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 17:49:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265965#M79953</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2016-10-19T17:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare search results from 2 dates without using subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265966#M79954</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=f5 instance=test (earliest=-4d@d latest=-3d@d) OR (earliest=-2d@d latest=-1d@d) 
| eval when=if(_time&amp;lt;=relative_time(now(), "-3d"), "Old", "New")
| eval urlall=split(uri,"?") 
| eval url=mvindex(urlall,0)+"*" 
| chart count avg(reqtime) as avgtime over url by when
| sort - avgtimeold 
| where count&amp;gt;100 
| head 30 
| rename count as countold 
| eval avgtimediff=new-old 
| eval avgtimediffpercent=tostring(floor(avgtimediff*100/avgtimeold))+"%" 
| eval countdiff=countnew-countold 
| eval countdiffpercent=tostring(floor(countdiff*100/countold))+"%" 
| table url,countold,countnew,countdiff,countdiffpercent,avgtimeold,avgtimenew,avgtimediff,avgtimediffpercent
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2016 17:53:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265966#M79954</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-19T17:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare search results from 2 dates without using subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265967#M79955</link>
      <description>&lt;P&gt;I am on 6.4.2.  Is there something in 6.5 that will make this super easy?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 18:05:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265967#M79955</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2016-10-19T18:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare search results from 2 dates without using subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265968#M79956</link>
      <description>&lt;P&gt;Looks sweet. I will give it a try and will get back to you. Thank you again for working out the query.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 18:06:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265968#M79956</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2016-10-19T18:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare search results from 2 dates without using subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265969#M79957</link>
      <description>&lt;P&gt;Something along these lines. I took out your sort and head commands, as I wasn't sure how you'd want to cut off the values. :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=f5 instance=test earliest=-4d@d latest=-1d@d 
| eval urlall=split(uri,"?") 
| eval url=mvindex(urlall,0)+"*" 
| eval timeFrame=if(relative_time(now(),"-2d@d")&amp;gt;=_time,"old","new")
| chart count avg(reqtime) as avgtime by url timeFrame
| rename "count: old" as countold "count: new" as countnew "avgtime: old" as avgtimeold "avgtime: new" as avgtimenew
| where count&amp;gt;100 
| eval avgtimediff=avgtimenew-avgtimeold 
| eval avgtimediffpercent=tostring(floor(avgtimediff*100/avgtimeold))+"%" 
| eval countdiff=countnew-countold 
| eval countdiffpercent=tostring(floor(countdiff*100/countold))+"%" 
| table url,countold,countnew,countdiff,countdiffpercent,avgtimeold,avgtimenew,avgtimediff,avgtimediffpercent
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2016 18:09:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265969#M79957</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2016-10-19T18:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare search results from 2 dates without using subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265970#M79958</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=f5 instance=test (earliest=-4d@d latest=-3d@d) OR (earliest=-2d@d latest=-1d@d) 
| eval when=if(_time&amp;lt;=relative_time(now(), "-3d"), "Old", "New") 
| eval urlall=split(uri,"?") 
| eval url=mvindex(urlall,0)+"*" 
| chart count avg(reqtime) as avgtime over url by when
| sort - avgtimeOld
| where countOld &amp;gt; 100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This query doesn't produce results. When I take out the where it does. Am I screwing up the field names? They show in splunk as "count: Old"&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 20:27:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265970#M79958</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2016-10-19T20:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare search results from 2 dates without using subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265971#M79959</link>
      <description>&lt;P&gt;Nevermind,  I used the rename from cmerriman's response and it seems to work.  Thank you both for the great help.  This query is nice!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 20:33:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265971#M79959</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2016-10-19T20:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare search results from 2 dates without using subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265972#M79960</link>
      <description>&lt;P&gt;One last question on this topic.  &lt;/P&gt;

&lt;P&gt;Works&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval when=if(_time&amp;lt;=if(isnum(1476860400),1476860400,relative_time(now(),"1476860400")), "old", "new")
eval when=if(_time&amp;lt;=if(isnum("-3d@d"),"-3d@d",relative_time(now(),"-3d@d")), "old", "new")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Doesn't Work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;when=if(_time&amp;lt;=if(isnum("1476860400"),"1476860400",relative_time(now(),"1476860400")), "old", "new")
eval when=if(_time&amp;lt;=if(isnum(-3d@d),-3d@d,relative_time(now(),"-3d@d")), "old", "new")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My problem is, I can't figure out how to do the query where it can take calendar and relative times from the time picker.  Quotes are needed for the relative and not for the calendar (epoch).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=f5 instance=test (earliest=1476774000 latest=1476860400) OR (earliest=1476946800 latest=1477033200) | eval when=if(_time&amp;lt;=if(isnum(1476860400),1476860400,relative_time(now(),"1476860400")), "old", "new") | eval urlall=split(uri,"?") | eval url=mvindex(urlall,0)+"*" | chart count avg(reqtime) as avgtime over url by when | rename "count: old" as countold "count: new" as countnew "avgtime: old" as avgtimeold "avgtime: new" as avgtimenew | sort - avgtimeold | where countold &amp;gt; 100 | head 30 | eval avgtimediff=avgtimenew - avgtimeold | eval avgtimediffpercent=tostring(floor(avgtimediff*100/avgtimeold))+"%" | eval countdiff=countnew-countold | eval countdiffpercent=tostring(floor(countdiff*100/countold))+"%" | table url,countold,countnew,countdiff,countdiffpercent,avgtimeold,avgtimenew,avgtimediff,avgtimediffpercent
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Oct 2016 16:12:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265972#M79960</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2016-10-21T16:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare search results from 2 dates without using subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265973#M79961</link>
      <description>&lt;P&gt;heh, think i found a solution.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval timea = if(len("$timeRangeOld.latest$") &amp;lt; 10,relative_time(now(),"$timeRangeOld.latest$","$timeRangeOld.latest$") | eval when=if(_time&amp;lt;=timea, "old", "new")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Oct 2016 17:26:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-search-results-from-2-dates-without-using/m-p/265973#M79961</guid>
      <dc:creator>wweiland</dc:creator>
      <dc:date>2016-10-21T17:26:41Z</dc:date>
    </item>
  </channel>
</rss>

