<?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: Overlay 2 time based grouped results in a Chart in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158051#M44543</link>
    <description>&lt;P&gt;If you want to optimize your search (instead of using an append), you could do a search for -60d - now and then do evals based on whether time is more than 30 days or not (case or if).&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jan 2020 08:30:23 GMT</pubDate>
    <dc:creator>brettcave</dc:creator>
    <dc:date>2020-01-07T08:30:23Z</dc:date>
    <item>
      <title>Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158033#M44525</link>
      <description>&lt;P&gt;Given the 2 following searches which are both over a 30 day period (and each having multiple countries in the results) how do I:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Show the time as day range (0-30) instead of the actual dates showing&lt;/LI&gt;
&lt;LI&gt;Then overlay the 2 search results into the same line chart (as they are both over a 30 day period)&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;The searches are:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt; earliest=-60d@d latest=-30d@d  | rex "country=(?&amp;lt;Country&amp;gt;[a-zA-Z]*)\s" | bin _time span=1d | stats count as DailyTotal by Country _time| timechart avg(DailyTotal) as AvgPerDay by Country
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt; earliest=-30d@d latest=now  | rex "country=(?&amp;lt;Country&amp;gt;[a-zA-Z]*)\s" | bin _time span=1d | stats count as DailyTotal by Country _time| timechart avg(DailyTotal) as AvgPerDay by Country
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After hours of searching - this result produces overlaid lines BUT NOT with the 'Country' grouping and the chart time period shows 60 days not 30...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-60d@d latest=now  | rex "country=(?&amp;lt;Country&amp;gt;[a-zA-Z]*)\s" | bin _time span=1d | stats count as DailyTotal by Country _time| eval marker=if(_time&amp;lt;relative_time(now(), "-30d@d"), "Last Month", "This Month") | eval _time=if(marker=="Last Month", _time+(60*60*24*30), _time) |  timechart avg(DailyTotal) as AvgPerDay by marker
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I get the grouping back?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 10:54:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158033#M44525</guid>
      <dc:creator>GadgetGeek</dc:creator>
      <dc:date>2015-08-10T10:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158034#M44526</link>
      <description>&lt;P&gt;You need the &lt;CODE&gt;timewrap&lt;/CODE&gt; app, for sure:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://splunkbase.splunk.com/app/1645/"&gt;https://splunkbase.splunk.com/app/1645/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 12:55:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158034#M44526</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-10T12:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158035#M44527</link>
      <description>&lt;P&gt;We can't use any additional plugins...&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 12:59:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158035#M44527</guid>
      <dc:creator>GadgetGeek</dc:creator>
      <dc:date>2015-08-10T12:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158036#M44528</link>
      <description>&lt;P&gt;Download the app and clone the guts manually.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 13:05:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158036#M44528</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-10T13:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158037#M44529</link>
      <description>&lt;P&gt;First of all, you're doing unnecessary oparations - after bucketing by day and then counting by day, averaging by day is futile. So you could change your first search to the following and it should do the same, only quicker:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-60d@d latest=-30d@d  | rex "country=(?&amp;lt;Country&amp;gt;[a-zA-Z]*)\s" | timechart span=1d count as CountPerDay by Country
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, on to your original problem. To show a day instead of a date, you need to eval &lt;CODE&gt;_time&lt;/CODE&gt; with &lt;CODE&gt;strftime&lt;/CODE&gt;. In your case, that would yield something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-60d@d latest=-30d@d  | rex "country=(?&amp;lt;Country&amp;gt;[a-zA-Z]*)\s" | eval day=strftime(_time, "%d") | chart avg(DailyTotal) as AvgPerDay by day Country
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;for the first search.&lt;/P&gt;

&lt;P&gt;To overlay two different time ranges in one timechart, you generally need to eval the &lt;CODE&gt;_time&lt;/CODE&gt; field of one of the searches to the same period as the other one (so 30 days ahead in your case). See &lt;A href="http://blogs.splunk.com/2012/02/19/compare-two-time-ranges-in-one-report/"&gt;this blog post&lt;/A&gt; for details. The problem is, you will need to do this &lt;EM&gt;before&lt;/EM&gt; you count by your new &lt;CODE&gt;day&lt;/CODE&gt; field because that one can't be used to go back 30 days. So your searches could end up something like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-30d@d latest=now | rex "country=(?&amp;lt;Country&amp;gt;[a-zA-Z]*)\s" | eval key="this month" | eval day=strftime(_time, "%d") | append [search earliest=-60d@d latest=-30d@d  | rex "country=(?&amp;lt;Country&amp;gt;[a-zA-Z]*)\s" | eval key="last month" | eval _time=_time+2592000 | eval day=strftime(_time, "%d")] | eval key=Country." ".key | chart count by day key
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've had to change the calculation of &lt;CODE&gt;_time&lt;/CODE&gt; to an external field sometimes, so if the above doesn't do the trick this one might:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-30d@d latest=now | rex "country=(?&amp;lt;Country&amp;gt;[a-zA-Z]*)\s" | eval key="this month" | eval day=strftime(_time, "%d") | append [search earliest=-60d@d latest=-30d@d  | rex "country=(?&amp;lt;Country&amp;gt;[a-zA-Z]*)\s" | eval key="last month" | eval time=_time+2592000 | eval day=strftime(_time, "%d")] | eval _time=if(key="last month",time,_time) | eval key=Country." ".key | chart count by day key
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See how far you get and feel free to ask questions if something doesn't work out.&lt;BR /&gt;
PS: I've edited some of the search in this answer, it should now work.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 13:18:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158037#M44529</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-08-10T13:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158038#M44530</link>
      <description>&lt;P&gt;You're right on the first part - counting was what I should have done!&lt;/P&gt;

&lt;P&gt;But I get some strange results using both the last answers! I was expecting 2 lines in the chart per country (one for the last 30 days, one for the previous 30 days to that). I'm left with: &lt;/P&gt;

&lt;P&gt;3 lines: key, Country, count - none of which make sense - neither do the axes&lt;/P&gt;

&lt;P&gt;I'm too new at this to get to grips with it, but this seems further away than at the start?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 13:29:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158038#M44530</guid>
      <dc:creator>GadgetGeek</dc:creator>
      <dc:date>2015-08-10T13:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158039#M44531</link>
      <description>&lt;P&gt;Sorry, there was a &lt;CODE&gt;stats&lt;/CODE&gt; instead of a &lt;CODE&gt;chart&lt;/CODE&gt; in the final version. Please try again.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 13:33:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158039#M44531</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-08-10T13:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158040#M44532</link>
      <description>&lt;P&gt;Now I get:&lt;/P&gt;

&lt;P&gt;Error in 'chart' command: The argument 'Country' is invalid. &lt;/P&gt;

&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 13:39:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158040#M44532</guid>
      <dc:creator>GadgetGeek</dc:creator>
      <dc:date>2015-08-10T13:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158041#M44533</link>
      <description>&lt;P&gt;Damn, yeah I just noticed this can't work - chart only accepts two split-by arguments (there are only two axes). Lemme work some more on that.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 13:41:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158041#M44533</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-08-10T13:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158042#M44534</link>
      <description>&lt;P&gt;Your help is most appreciated! (Even when it doesn't work &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; )&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 13:43:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158042#M44534</guid>
      <dc:creator>GadgetGeek</dc:creator>
      <dc:date>2015-08-10T13:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158043#M44535</link>
      <description>&lt;P&gt;Ok, please try again.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 13:48:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158043#M44535</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-08-10T13:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158044#M44536</link>
      <description>&lt;P&gt;I think that's it - just off to check the numbers.....&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 13:54:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158044#M44536</guid>
      <dc:creator>GadgetGeek</dc:creator>
      <dc:date>2015-08-10T13:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158045#M44537</link>
      <description>&lt;P&gt;Yes it works - with a caveat...&lt;/P&gt;

&lt;P&gt;Is there any way to get it to have the numbering on the time axis being from -30 to 0?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 14:13:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158045#M44537</guid>
      <dc:creator>GadgetGeek</dc:creator>
      <dc:date>2015-08-10T14:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158046#M44538</link>
      <description>&lt;P&gt;Oh, spotted that you use 'if (key="previous month"... but the search uses "last month"&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 14:52:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158046#M44538</guid>
      <dc:creator>GadgetGeek</dc:creator>
      <dc:date>2015-08-10T14:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158047#M44539</link>
      <description>&lt;P&gt;Adding the search criteria back into the 2nd search (after append) helps! Better numbers coming out now...&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2015 15:02:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158047#M44539</guid>
      <dc:creator>GadgetGeek</dc:creator>
      <dc:date>2015-08-10T15:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158048#M44540</link>
      <description>&lt;P&gt;I corrected that in the answer, thanks for pointing it out.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2015 05:23:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158048#M44540</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-08-11T05:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158049#M44541</link>
      <description>&lt;P&gt;Definitely. I assume you want -30 instead of 0 and 0 instead of 30, then simply add an eval for that somewhere:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval day=day-30
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Aug 2015 05:25:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158049#M44541</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-08-11T05:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158050#M44542</link>
      <description>&lt;P&gt;Thanks for getting me there in the end - and I learned a lot along the way!!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2015 05:36:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158050#M44542</guid>
      <dc:creator>GadgetGeek</dc:creator>
      <dc:date>2015-08-12T05:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158051#M44543</link>
      <description>&lt;P&gt;If you want to optimize your search (instead of using an append), you could do a search for -60d - now and then do evals based on whether time is more than 30 days or not (case or if).&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2020 08:30:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158051#M44543</guid>
      <dc:creator>brettcave</dc:creator>
      <dc:date>2020-01-07T08:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay 2 time based grouped results in a Chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158052#M44544</link>
      <description>&lt;P&gt;Something like this: &lt;BR /&gt;
    earliest="-60d@d" latest=now .... &lt;BR /&gt;
    |  eval key=if(_time &amp;gt; relative_time(now(), "-30d@h"),"currentPeriod","previousPeriod") | eval _time=if(key="previousPeriod",_time+604800,_time) | eval key=Country." ".key | timechart ..&lt;/P&gt;

&lt;P&gt;Not using chart with day, but timechart with the _time field.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:32:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Overlay-2-time-based-grouped-results-in-a-Chart/m-p/158052#M44544</guid>
      <dc:creator>brettcave</dc:creator>
      <dc:date>2020-09-30T03:32:13Z</dc:date>
    </item>
  </channel>
</rss>

