<?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 Two query results overlay on same graph in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Two-query-results-overlay-on-same-graph/m-p/144569#M40253</link>
    <description>&lt;P&gt;Trying to display a timechart with results for a time frame for a certain timespan from today, and then a day in the past, and overlay them on the same graph.  I found a few examples and was able to do this when displaying continuous results like today vs yesterday, but in this case i just want to do, for this example, results from today 7am-9am, and 7am-9am 7 days ago.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;first search earliest="02/10/2014:07:00:00" latest="02/10/2014:09:00:00"| eval timeVal=seconds+microsec/1000000| eval ReportKey="today" | append [search secondSearch earliest="02/03/2014:07:00:00" latest="02/03/2014:09:00:00"| eval timeVal=seconds+microsec/1000000| eval ReportKey="7 days ago"]| timechart avg(timeVal) as "InsertTime" span=10m by ReportKey
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 10 Feb 2014 18:39:03 GMT</pubDate>
    <dc:creator>ngvella</dc:creator>
    <dc:date>2014-02-10T18:39:03Z</dc:date>
    <item>
      <title>Two query results overlay on same graph</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-query-results-overlay-on-same-graph/m-p/144569#M40253</link>
      <description>&lt;P&gt;Trying to display a timechart with results for a time frame for a certain timespan from today, and then a day in the past, and overlay them on the same graph.  I found a few examples and was able to do this when displaying continuous results like today vs yesterday, but in this case i just want to do, for this example, results from today 7am-9am, and 7am-9am 7 days ago.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;first search earliest="02/10/2014:07:00:00" latest="02/10/2014:09:00:00"| eval timeVal=seconds+microsec/1000000| eval ReportKey="today" | append [search secondSearch earliest="02/03/2014:07:00:00" latest="02/03/2014:09:00:00"| eval timeVal=seconds+microsec/1000000| eval ReportKey="7 days ago"]| timechart avg(timeVal) as "InsertTime" span=10m by ReportKey
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Feb 2014 18:39:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-query-results-overlay-on-same-graph/m-p/144569#M40253</guid>
      <dc:creator>ngvella</dc:creator>
      <dc:date>2014-02-10T18:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Two query results overlay on same graph</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-query-results-overlay-on-same-graph/m-p/144570#M40254</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;firstSearch earliest=-7d@d+7h latest=-7d@d+9h
| eval timeVal=seconds+microsec/1000000
| eval ReportKey="7 days ago" 
| eval _time = _time + (7 * 86400)
| append [search secondSearch earliest=@d+7h latest=@d+9h
     | eval timeVal=seconds+microsec/1000000 | eval ReportKey="Today" ]
| timechart avg(timeVal) as "InsertTime" span=10m by ReportKey
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Two things: first, I have more luck with the older time range as the outer search. Also, you need to re-calculate the &lt;CODE&gt;_time&lt;/CODE&gt; for the older time range so that it aligns with the new time range. &lt;CODE&gt;| eval _time = _time + (7 * 86400)&lt;/CODE&gt; does that.&lt;/P&gt;

&lt;P&gt;Finally, you could do this without the &lt;CODE&gt;append&lt;/CODE&gt;, which would probably be more efficient - IF the first search and the second search are the same:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourSearch earliest=-7d@d+7h latest=@d+9h
| eval ReportKey = case (_time &amp;lt;= relative_time(now(),"-7d@d+9h"), "7 days ago",
                         _time &amp;gt;= relative_time(now(),"@d+7h"), "Today",
                         1==1, "skip")
| where ReportKey != "skip"
| eval _time = if(ReportKey=="Today",_time,_time + (7 * 86400))
| eval timeVal=seconds+microsec/1000000
| timechart avg(timeVal) as "InsertTime" span=10m by ReportKey
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Feb 2014 07:19:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-query-results-overlay-on-same-graph/m-p/144570#M40254</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-02-11T07:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Two query results overlay on same graph</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-query-results-overlay-on-same-graph/m-p/144571#M40255</link>
      <description>&lt;P&gt;Works great, thank you.  Can you explain to me what this bit is doing though?&lt;/P&gt;

&lt;P&gt;1==1&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2014 14:49:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-query-results-overlay-on-same-graph/m-p/144571#M40255</guid>
      <dc:creator>ngvella</dc:creator>
      <dc:date>2014-02-12T14:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Two query results overlay on same graph</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-query-results-overlay-on-same-graph/m-p/144572#M40256</link>
      <description>&lt;P&gt;It's the "default" statement for case(). It's a true condition that will always match.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2014 15:08:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-query-results-overlay-on-same-graph/m-p/144572#M40256</guid>
      <dc:creator>sowings</dc:creator>
      <dc:date>2014-02-12T15:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Two query results overlay on same graph</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-query-results-overlay-on-same-graph/m-p/144573#M40257</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Comparing week-over-week results used to a pain in Splunk, with complex date calculations. No more.  Now there is a better way.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I wrote a convenient search command called "&lt;A href="http://apps.splunk.com/app/1645/"&gt;timewrap&lt;/A&gt;" that does it all, for arbitrary time periods.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | timechart count span=1d | timewrap w
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That's it!&lt;/P&gt;

&lt;P&gt;&lt;A href="http://apps.splunk.com/app/1645/"&gt;http://apps.splunk.com/app/1645/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 May 2014 18:59:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-query-results-overlay-on-same-graph/m-p/144573#M40257</guid>
      <dc:creator>carasso</dc:creator>
      <dc:date>2014-05-21T18:59:24Z</dc:date>
    </item>
  </channel>
</rss>

