<?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: bucket from relative time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/bucket-from-relative-time/m-p/358238#M105916</link>
    <description>&lt;P&gt;I think &lt;CODE&gt;relative_time&lt;/CODE&gt; will solve your problem&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/DateandTimeFunctions#relative_time.28X.2CY.29"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/DateandTimeFunctions#relative_time.28X.2CY.29&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | eval n=relative_time(now(), "-1d@d")&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Dec 2017 14:41:39 GMT</pubDate>
    <dc:creator>skoelpin</dc:creator>
    <dc:date>2017-12-28T14:41:39Z</dc:date>
    <item>
      <title>bucket from relative time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/bucket-from-relative-time/m-p/358237#M105915</link>
      <description>&lt;P&gt;good day!&lt;BR /&gt;
when solving the problem of obtaining statistics, they encountered a problem. It is necessary to calculate the average number of events for a specific query. When using the bucket, the information is collected from the beginning of the hour. It is necessary to receive information from the current moment. If it's now 10.15, then you need to collect data from 08.15 to 09.15, then from 09.15 to 10.15 and so on.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;query 
| bucket _time span=1h
| stats count as tCount by _time
| eventstats avg(tCount) as aCount
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Dec 2017 11:19:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/bucket-from-relative-time/m-p/358237#M105915</guid>
      <dc:creator>yav2810</dc:creator>
      <dc:date>2017-12-28T11:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: bucket from relative time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/bucket-from-relative-time/m-p/358238#M105916</link>
      <description>&lt;P&gt;I think &lt;CODE&gt;relative_time&lt;/CODE&gt; will solve your problem&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/DateandTimeFunctions#relative_time.28X.2CY.29"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/DateandTimeFunctions#relative_time.28X.2CY.29&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | eval n=relative_time(now(), "-1d@d")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 14:41:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/bucket-from-relative-time/m-p/358238#M105916</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2017-12-28T14:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: bucket from relative time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/bucket-from-relative-time/m-p/358239#M105917</link>
      <description>&lt;P&gt;You can use &lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Streamstats"&gt;streamstats&lt;/A&gt; for that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;query
| streamstats time_window=1h count

time_window
Syntax: time_window=&amp;lt;span-length&amp;gt;
Description: Specifies the window size for the streamstats calculations, based on time. The time_window argument is limited by range of values in the _time field in the events. To use the time_window argument, the events must be sorted in either ascending or descending time order. You can use the window argument with the time_window argument to specify the maximum number of events in a window. For the &amp;lt;span-length&amp;gt;, to specify five minutes, use time_window=5m. To specify 2 days, use time_window=2d.
Default: None. However, the value of the max_stream_window attribute in the limits.conf file applies. The default value is 10000 events.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note: this may not be a very efficient search, depending on how much data you have.  You should probably consider using &lt;CODE&gt;stats&lt;/CODE&gt; on a smaller time period bucket (perhaps 1min) before piping the results into &lt;CODE&gt;streamstats&lt;/CODE&gt;, so that you don't run into performance or limits issues.  &lt;CODE&gt;streamstats&lt;/CODE&gt; also retains the raw event and existing extracted fields, so including &lt;CODE&gt;stats&lt;/CODE&gt; before it would limit that to only fields you actually care about.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;query
| bin span=1min _time
| stats count BY _time
| streamstats time_window=1h sum(count) AS count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Dec 2017 15:50:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/bucket-from-relative-time/m-p/358239#M105917</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2017-12-28T15:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: bucket from relative time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/bucket-from-relative-time/m-p/358240#M105918</link>
      <description>&lt;P&gt;See this answer &lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/581635/can-i-use-relative-time-for-bin-span.html"&gt;https://answers.splunk.com/answers/581635/can-i-use-relative-time-for-bin-span.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 15:52:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/bucket-from-relative-time/m-p/358240#M105918</guid>
      <dc:creator>naidusadanala</dc:creator>
      <dc:date>2017-12-28T15:52:38Z</dc:date>
    </item>
  </channel>
</rss>

