<?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: Why are bucket times expanding? in Deployment Architecture</title>
    <link>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489225#M16946</link>
    <description>&lt;P&gt;Try this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | bucket _time bins=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, BE SURE TO SET YOUR PERSONAL &lt;CODE&gt;Time zone&lt;/CODE&gt; setting: &lt;CODE&gt;Your Name Here&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Preferences&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Time zone&lt;/CODE&gt;.&lt;BR /&gt;
This looks like a bug and I would open a support ticket for sure.&lt;BR /&gt;
You can add this to the end:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where _time &amp;gt;= relative_time(now(), "-5h@h") AND _time &amp;lt;= relative_time(now(), "-1h@h")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 22 Nov 2019 20:51:02 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-11-22T20:51:02Z</dc:date>
    <item>
      <title>Why are bucket times expanding?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489224#M16945</link>
      <description>&lt;P&gt;I've read a few other forum posts with similar issues but I never found a true solution for. Overall I'm trying to mock up some correlation rules within Enterprise Security where my time frame is going to be -5h@h to &lt;A href="mailto:-1h@h"&gt;-1h@h&lt;/A&gt;. I want to make this into two bucks so I can compare two hour time frames against one another.&lt;/P&gt;

&lt;P&gt;I continually get 3 buckets even though there should only be two.&lt;/P&gt;

&lt;P&gt;In my most recent test I did this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=os_windows* OR index=os_unix*) (source=WinEventLog:Security OR sourcetype=linux_secure OR tag=authentication) action=failure NOT Result_Code=0x17 NOT Account_Name="*$"  earliest=-5h@h latest=-1h@h
| bucket _time span=2h 
| stats values(user) AS affected_users, values(ComputerName) as dc, dc(user) AS num_users count BY src_ip _time 
| where num_users &amp;gt; 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I look at the results, I see multiple src_ip's that have a 9:00, 11:00, and 13:00 row. It's currently 2:30 pm so the breakdown is:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;2:30   = current time&lt;BR /&gt;
1:30   = -1h@h&lt;BR /&gt;
12:30 = -2h@h&lt;BR /&gt;
11:30 = -3h@h&lt;BR /&gt;
10:30 = -4h@h&lt;BR /&gt;
09:30 = -5h@h&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;So I should have a 9:00 - 11:00 bucket and an 11:00 - 1:00 bucket. I have no idea why it's also showing me a 13:00 bucket in my search results. This is throwing off my math since that number is quite a bit different as I assume it's not the full hour and it's not snapping correctly or something.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 20:32:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489224#M16945</guid>
      <dc:creator>ericl42</dc:creator>
      <dc:date>2019-11-22T20:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why are bucket times expanding?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489225#M16946</link>
      <description>&lt;P&gt;Try this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | bucket _time bins=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, BE SURE TO SET YOUR PERSONAL &lt;CODE&gt;Time zone&lt;/CODE&gt; setting: &lt;CODE&gt;Your Name Here&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Preferences&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Time zone&lt;/CODE&gt;.&lt;BR /&gt;
This looks like a bug and I would open a support ticket for sure.&lt;BR /&gt;
You can add this to the end:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where _time &amp;gt;= relative_time(now(), "-5h@h") AND _time &amp;lt;= relative_time(now(), "-1h@h")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Nov 2019 20:51:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489225#M16946</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-22T20:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Why are bucket times expanding?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489226#M16947</link>
      <description>&lt;P&gt;Thanks for the quick response. I like the concept of bins so I always know it's two items I'm comparing against vs. potentially three. I tried this on on my query and the time just now says 2019-11-22 and doesn't have another hour or delimiter. So basically even though I said 2 bins, I'm only seeing one row per user ID.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 21:27:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489226#M16947</guid>
      <dc:creator>ericl42</dc:creator>
      <dc:date>2019-11-22T21:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why are bucket times expanding?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489227#M16948</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;2:30 = current time
1:00 = -1h@h
12:00 = -2h@h
11:00 = -3h@h
10:00 = -4h@h
09:00 = -5h@h
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi,  &lt;EM&gt;@h&lt;/EM&gt; is offset at the beginning of the time, so this is correct.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 00:24:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489227#M16948</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-24T00:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Why are bucket times expanding?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489228#M16949</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; (index=os_windows* OR index=os_unix*) (source=WinEventLog:Security OR sourcetype=linux_secure OR tag=authentication) action=failure NOT Result_Code=0x17 NOT Account_Name="*$"  earliest=-5h@h latest=-1h@h
| timechart span=2h values(user) AS affected_users, values(ComputerName) as dc, dc(user) AS num_users count BY src_ip
| where num_users &amp;gt; 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, How about obediently &lt;CODE&gt;timechart&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 00:39:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489228#M16949</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-24T00:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: Why are bucket times expanding?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489229#M16950</link>
      <description>&lt;P&gt;Timechart may work for this one scenario, but I have others where I count by multiple fields and timechart only allows me to do one.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 14:34:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489229#M16950</guid>
      <dc:creator>ericl42</dc:creator>
      <dc:date>2019-11-25T14:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Why are bucket times expanding?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489230#M16951</link>
      <description>&lt;P&gt;Like &lt;CODE&gt;makeresults&lt;/CODE&gt; , &lt;CODE&gt;bin&lt;/CODE&gt;  seems to make the last time when it makes time.&lt;/P&gt;

&lt;P&gt;If you really need two,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (index=os_windows* OR index=os_unix*) (source=WinEventLog:Security OR sourcetype=linux_secure OR tag=authentication) action=failure NOT Result_Code=0x17 NOT Account_Name="*$"  earliest=-5h@h latest=-1h@h
 | addinfo
 | eval sessionId = if(_time &amp;lt; relative_time(info_min_time,"+2h"),1,2)
 | stats earliest(_time) as _time values(user) AS affected_users, values(ComputerName) as dc, dc(user) AS num_users count BY src_ip sessionId
 | where num_users &amp;gt; 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With this query, the search period is divided into the first 2 hours and the rest, and the results are displayed.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 19:54:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489230#M16951</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-25T19:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why are bucket times expanding?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489231#M16952</link>
      <description>&lt;P&gt;Thanks for the response. After digging around a little, I think I may have fixed the issue by adding the aligntime portion. However I'll take a look at your new query as well.&lt;/P&gt;

&lt;P&gt;| bucket _time span=2h@h aligntime=-1h@h&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 20:12:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489231#M16952</guid>
      <dc:creator>ericl42</dc:creator>
      <dc:date>2019-11-25T20:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why are bucket times expanding?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489232#M16953</link>
      <description>&lt;P&gt;OK, I finally took the time to try this and I know what is happening.  Splunk is "too smart" here for its own good.  It knows that there are an even number of hours in a day so when you tell it to &lt;CODE&gt;bin _time span=2h&lt;/CODE&gt;, the buckets that it automatically creates fall on even-hour boundaries.  In your case, when you are displaying odd-numbered times, such as from 1PM-5PM, it is creating &lt;CODE&gt;3 even-hour-based&lt;/CODE&gt; buckets: &lt;CODE&gt;12-2, 2-4, 4-6&lt;/CODE&gt;, instead of &lt;CODE&gt;2 odd-based&lt;/CODE&gt; buckets: &lt;CODE&gt;1-3, 3-5&lt;/CODE&gt;.  I believe that @rich7177 has experimented and pontificated at length about this and perhaps he will post a comment or a link.  In any case, now that I understand the fundamental nature of the problem, I believe that it can be addressed like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;((index="os_windows*" AND source=WinEventLog:Security) OR (index="os_unix*" ANDsourcetype=linux_secure) OR tag=authentication) AND action=failure  AND NOT (Result_Code="0x17" OR Account_Name="*$") earliest=-5h@h latest=-1h@h
| bucket _time span=2h aligntime=-1h@h
| stats values(user) AS affected_users, values(ComputerName) AS dc, dc(user) AS num_users count BY src_ip _time 
| where num_users &amp;gt; 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively you might consider starting over and using a &lt;CODE&gt;sliding window&lt;/CODE&gt; instead of a &lt;CODE&gt;discretized window&lt;/CODE&gt; with &lt;CODE&gt;streamstats time_window=2h&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 01:08:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489232#M16953</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-26T01:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Why are bucket times expanding?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489233#M16954</link>
      <description>&lt;P&gt;Thank you very much. Yesterday before this post I accidentally started testing with aligntime and it seemed to fix the issue but I wasn't 100% why. I don't think I can use sliding windows because I'm mocking all of these rules up for ES correlation searches.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 14:44:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/Why-are-bucket-times-expanding/m-p/489233#M16954</guid>
      <dc:creator>ericl42</dc:creator>
      <dc:date>2019-11-26T14:44:40Z</dc:date>
    </item>
  </channel>
</rss>

