<?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 edit my timechart search to compare counts over the last two weeks, and show the count trend in a single value visualization? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223002#M65600</link>
    <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search earliest=-14@d 
| eval _time=if(_time&amp;lt;relative_time(now(),"-7d@d"), relative_time(now(),"-7d@d"),relative_time(now(),"@d")
| timechart span=7d count | reverse | head 2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 08 Nov 2016 19:29:49 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-11-08T19:29:49Z</dc:date>
    <item>
      <title>How to edit my timechart search to compare counts over the last two weeks, and show the count trend in a single value visualization?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/222998#M65596</link>
      <description>&lt;P&gt;Hello Splunk experts - &lt;/P&gt;

&lt;P&gt;Not sure how to tackle this problem, hoping someone can assist. &lt;/P&gt;

&lt;P&gt;I am trying to compare counts over the last two weeks and use the single value viz to show the count trend.  The problem I'm running into is; although I am filtering the events and they start with the earliest event beginning on 2016-10-26 going through 2016-11-08, the timechart command seems to break the events into four groups (as shown below).  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-10-21  301
2016-10-28  699
2016-11-01  1200
2016-11-08  5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I go to show the trend, it then uses the last two values (or first 2 if I use reverse), which is an incorrect representation of what I am trying to do.  &lt;/P&gt;

&lt;P&gt;Is there a way to have it sum or combine the top 2 and bottom 2 values.  Something like below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    2016-10-28  1000
    2016-11-08  1205
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've tried using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|searchHere  otherFiltering earliest=-14d@d | timechart count span=7d
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any way to work around this issue?  Thanks a bunch for the help in advanced.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2016 06:08:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/222998#M65596</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2016-11-08T06:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my timechart search to compare counts over the last two weeks, and show the count trend in a single value visualization?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/222999#M65597</link>
      <description>&lt;P&gt;Can you please try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base query earliest=-14d@d latest=-d@d
| timechart count span=7d
| eval _time=strftime(_time+7*24*60*60, "%Y-%m-%d")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;1) For last 14 days (excluding the current day) &lt;CODE&gt;earliest=-14d@d latest=-d@d&lt;/CODE&gt; is used to filter events strictly..&lt;BR /&gt;
2) Timechart will tend to group the event as &lt;CODE&gt;-14th day till -8th day&lt;/CODE&gt; and &lt;CODE&gt;-7th day till -1st day&lt;/CODE&gt; keeping the date as &lt;CODE&gt;-14th day&lt;/CODE&gt; and &lt;CODE&gt;-7th day&lt;/CODE&gt; respectively. &lt;CODE&gt;| eval _time=strftime(_time+7*24*60*60, "%Y-%m-%d")&lt;/CODE&gt; command is just to shift those &lt;CODE&gt;-14th day&lt;/CODE&gt; and &lt;CODE&gt;-7th day&lt;/CODE&gt; date to &lt;CODE&gt;-8th day&lt;/CODE&gt; and &lt;CODE&gt;yesterday&lt;/CODE&gt; respectively and give in the format you required for table.&lt;BR /&gt;
3) If you wanna use current day as well, adjust the earliest and latest accordingly as remember if you take earliest as &lt;CODE&gt;-14d&lt;/CODE&gt; and current as &lt;CODE&gt;todays day&lt;/CODE&gt; technically they are &lt;CODE&gt;15days&lt;/CODE&gt;. Timechart will then end up making three rows. In this case summing up the last two rows will actually be incorrect as the last row will represent data only for the single day which is &lt;CODE&gt;todays day&lt;/CODE&gt; and consequently the sum will be of 8days and not 7.&lt;/P&gt;

&lt;P&gt;If you want to try it, use &lt;CODE&gt;|head 2&lt;/CODE&gt; in the end to get rid of that one extra day.&lt;BR /&gt;
Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base query earliest=-14d@d 
    | timechart count span=7d
    | eval _time=strftime(_time+7*24*60*60, "%Y-%m-%d")
    | head 2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Nov 2016 07:48:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/222999#M65597</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-11-08T07:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my timechart search to compare counts over the last two weeks, and show the count trend in a single value visualization?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223000#M65598</link>
      <description>&lt;P&gt;Thanks for the reply gokadroid - Tried what you suggested and I still get the same results.  Timechart returns data for different week ranges, and the counts spread through each of those. &lt;/P&gt;

&lt;P&gt;2016-10-21    301&lt;BR /&gt;
 2016-10-28    699&lt;BR /&gt;
 2016-11-01    1200&lt;BR /&gt;
 2016-11-08    5&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2016 14:08:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223000#M65598</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2016-11-08T14:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my timechart search to compare counts over the last two weeks, and show the count trend in a single value visualization?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223001#M65599</link>
      <description>&lt;P&gt;Update: &lt;/P&gt;

&lt;P&gt;So I am looking for something like this, which gives me the breakdown by week.  What I am unsure of is; how do I use these counts with timechart or is there another way to get the single value trend without using timechart?  Whenever I try to use timechart the counts show up as 0. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|searchHere 
| eval a = relative_time(now(), "-7d@d") 
| eval b = relative_time(now(), "-0d@d") 
| eval filter = case(process_time &amp;gt; a, "Cur Week", process_time &amp;lt; b, "P week") 
| eval _time=strftime(process_time + 7*24*60*60, "%Y-%m-%d")
| stats count by filter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Cur week 1000
P week     1205
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Nov 2016 18:33:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223001#M65599</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2016-11-08T18:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my timechart search to compare counts over the last two weeks, and show the count trend in a single value visualization?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223002#M65600</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search earliest=-14@d 
| eval _time=if(_time&amp;lt;relative_time(now(),"-7d@d"), relative_time(now(),"-7d@d"),relative_time(now(),"@d")
| timechart span=7d count | reverse | head 2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Nov 2016 19:29:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223002#M65600</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-11-08T19:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my timechart search to compare counts over the last two weeks, and show the count trend in a single value visualization?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223003#M65601</link>
      <description>&lt;P&gt;This worked, but I have no clue why....Can you explain or point me to something that explains what you did.  Thanks for taking the time to help, much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2016 20:18:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223003#M65601</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2016-11-08T20:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my timechart search to compare counts over the last two weeks, and show the count trend in a single value visualization?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223004#M65602</link>
      <description>&lt;P&gt;Line1:....&lt;BR /&gt;
Line2: Updating the _time value. For any data that is older than &lt;CODE&gt;relative_time(now(),"-7d@d")&lt;/CODE&gt; e.g. if today is &lt;CODE&gt;2016-11-08&lt;/CODE&gt; , any data older than &lt;CODE&gt;2016-11-01&lt;/CODE&gt; will have the timestamp as &lt;CODE&gt;2016-11-01&lt;/CODE&gt;. Else it will have timestamp of &lt;CODE&gt;2016-11-08&lt;/CODE&gt; ( &lt;CODE&gt;relative_time(now(),"@d")&lt;/CODE&gt; ).&lt;BR /&gt;
Line3: regular timechart. Since the time range is effectively about 15 days, there will be 3 rows created but first row will have count of 0. So remove that.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:43:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223004#M65602</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T11:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my timechart search to compare counts over the last two weeks, and show the count trend in a single value visualization?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223005#M65603</link>
      <description>&lt;P&gt;Thanks for breaking it down for me.  &lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2016 21:23:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223005#M65603</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2016-11-08T21:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my timechart search to compare counts over the last two weeks, and show the count trend in a single value visualization?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223006#M65604</link>
      <description>&lt;P&gt;There shouldn't be a reason why when the span is 7d, there should be groupings of dates which are not 7 days apart, unless month end is playing a role for the dates 11/01 groupings to show up even though previous grouping of 10/28 is not 7 days apart.  Somesoni's answer actually tricks all the time values to get assigned to as one of the two values and should work then.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 02:47:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-timechart-search-to-compare-counts-over-the-last/m-p/223006#M65604</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-11-09T02:47:21Z</dc:date>
    </item>
  </channel>
</rss>

