<?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 Change the span start time defaults when using bin span=1w _time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Change-the-span-start-time-defaults-when-using-bin-span-1w-time/m-p/374827#M110171</link>
    <description>&lt;P&gt;Hi - I'm trying to display a count of all sources over a 4 week period for a specific source type as part of a data quality process.&lt;BR /&gt;
There are several sources for this source type which all get ingested once per week.  We want to look for issues where a source event count deviates significantly from the previous weeks.&lt;/P&gt;

&lt;P&gt;Across all sources there are approx 2M events indexed each week so I have started out using tstats to count events.&lt;BR /&gt;
I want to display the results in table format with the source column as the leftmost column and the count per week over the last 4 weeks as columns from newest to oldest in date order.  &lt;/P&gt;

&lt;P&gt;I'm hitting two problems - &lt;BR /&gt;
1) I can't get the span for each week to start at midnight Sunday &lt;BR /&gt;
2) I can't get the columns to be ordered from newest to oldest&lt;/P&gt;

&lt;P&gt;So far I have &lt;BR /&gt;
| tstats count where index=test_index sourcetype=test_st by source , _time span=1h &lt;BR /&gt;
| eval 4weeks= relative_time(now(),"-4w@w0")&lt;BR /&gt;
| where _time &amp;gt; 4weeks&lt;BR /&gt;
| sort source&lt;BR /&gt;
| bin span=1w _time&lt;BR /&gt;
| eval time=strftime(_time,@%m,%d")&lt;BR /&gt;
| chart values(count) as count over source by time&lt;/P&gt;

&lt;P&gt;Note I use span=1h on the tstats command as a file take several seconds to index so I want to only show one time for this source&lt;BR /&gt;
I have to also set a time field in order to have the time in a readable format - passing _time in the by clause on the chart command ends up with _time being display using unix time format.&lt;/P&gt;

&lt;P&gt;Search Results based on the search above&lt;/P&gt;

&lt;P&gt;source        04:10.       04:17.      04:24.   05:01&lt;BR /&gt;
source1.    267000.    209703.                 212682&lt;BR /&gt;
source2.   1019148.   1040676.               1040832&lt;BR /&gt;
source3.    28353.      29406.      29094&lt;BR /&gt;
source4     22542.     22620.       22549&lt;/P&gt;

&lt;P&gt;The results above are what I get when running today 3/5 - the span seems to start on Monday eg 05:01&lt;BR /&gt;
However as files are normally ingested on Sunday and Monday across all sources I see files for this week as showing in last week&lt;BR /&gt;
Also I'd prefer that the table was sorted newest to oldest from right to left.&lt;/P&gt;

&lt;P&gt;Any thoughts or suggestions welcome.  Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 19:20:53 GMT</pubDate>
    <dc:creator>skelly99</dc:creator>
    <dc:date>2020-09-29T19:20:53Z</dc:date>
    <item>
      <title>Change the span start time defaults when using bin span=1w _time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Change-the-span-start-time-defaults-when-using-bin-span-1w-time/m-p/374827#M110171</link>
      <description>&lt;P&gt;Hi - I'm trying to display a count of all sources over a 4 week period for a specific source type as part of a data quality process.&lt;BR /&gt;
There are several sources for this source type which all get ingested once per week.  We want to look for issues where a source event count deviates significantly from the previous weeks.&lt;/P&gt;

&lt;P&gt;Across all sources there are approx 2M events indexed each week so I have started out using tstats to count events.&lt;BR /&gt;
I want to display the results in table format with the source column as the leftmost column and the count per week over the last 4 weeks as columns from newest to oldest in date order.  &lt;/P&gt;

&lt;P&gt;I'm hitting two problems - &lt;BR /&gt;
1) I can't get the span for each week to start at midnight Sunday &lt;BR /&gt;
2) I can't get the columns to be ordered from newest to oldest&lt;/P&gt;

&lt;P&gt;So far I have &lt;BR /&gt;
| tstats count where index=test_index sourcetype=test_st by source , _time span=1h &lt;BR /&gt;
| eval 4weeks= relative_time(now(),"-4w@w0")&lt;BR /&gt;
| where _time &amp;gt; 4weeks&lt;BR /&gt;
| sort source&lt;BR /&gt;
| bin span=1w _time&lt;BR /&gt;
| eval time=strftime(_time,@%m,%d")&lt;BR /&gt;
| chart values(count) as count over source by time&lt;/P&gt;

&lt;P&gt;Note I use span=1h on the tstats command as a file take several seconds to index so I want to only show one time for this source&lt;BR /&gt;
I have to also set a time field in order to have the time in a readable format - passing _time in the by clause on the chart command ends up with _time being display using unix time format.&lt;/P&gt;

&lt;P&gt;Search Results based on the search above&lt;/P&gt;

&lt;P&gt;source        04:10.       04:17.      04:24.   05:01&lt;BR /&gt;
source1.    267000.    209703.                 212682&lt;BR /&gt;
source2.   1019148.   1040676.               1040832&lt;BR /&gt;
source3.    28353.      29406.      29094&lt;BR /&gt;
source4     22542.     22620.       22549&lt;/P&gt;

&lt;P&gt;The results above are what I get when running today 3/5 - the span seems to start on Monday eg 05:01&lt;BR /&gt;
However as files are normally ingested on Sunday and Monday across all sources I see files for this week as showing in last week&lt;BR /&gt;
Also I'd prefer that the table was sorted newest to oldest from right to left.&lt;/P&gt;

&lt;P&gt;Any thoughts or suggestions welcome.  Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:20:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Change-the-span-start-time-defaults-when-using-bin-span-1w-time/m-p/374827#M110171</guid>
      <dc:creator>skelly99</dc:creator>
      <dc:date>2020-09-29T19:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Change the span start time defaults when using bin span=1w _time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Change-the-span-start-time-defaults-when-using-bin-span-1w-time/m-p/374828#M110172</link>
      <description>&lt;P&gt;You have to do it in SPL like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_audit date_wday=*
| dedup date_wday
| bin _time span=1w 
| table _time date_wday
| eval _time=_time - (tonumber(strftime(now(), "%w")) * 60 * 60 *24)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 May 2018 14:21:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Change-the-span-start-time-defaults-when-using-bin-span-1w-time/m-p/374828#M110172</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-05-03T14:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Change the span start time defaults when using bin span=1w _time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Change-the-span-start-time-defaults-when-using-bin-span-1w-time/m-p/374829#M110173</link>
      <description>&lt;P&gt;Thanks for the suggestion - unfortunately the raw events don't have timestamps so I don't get the date-* fields.   &lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 09:30:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Change-the-span-start-time-defaults-when-using-bin-span-1w-time/m-p/374829#M110173</guid>
      <dc:creator>skelly99</dc:creator>
      <dc:date>2018-05-04T09:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Change the span start time defaults when using bin span=1w _time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Change-the-span-start-time-defaults-when-using-bin-span-1w-time/m-p/374830#M110174</link>
      <description>&lt;P&gt;OK, so you create the field, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your Base Search Here
| eval date_wday = strftime(_time, "%a")
| dedup date_wday
| bin _time span=1w 
| table _time date_wday
| eval _time=_time - (tonumber(strftime(now(), "%w")) * 60 * 60 *24)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 May 2018 21:53:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Change-the-span-start-time-defaults-when-using-bin-span-1w-time/m-p/374830#M110174</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-05-04T21:53:35Z</dc:date>
    </item>
  </channel>
</rss>

