<?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: Search buckets span=18h in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37267#M8309</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I think it's very hard with the use of earliest and latest to do it for last 2 months. The best way i could think of is like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=infra_nb sourcetype=nbjobs earliest=-2mon@mon latest=@mon|eval ignore_hour=strftime("_time","%H")|where ignore_hour &amp;lt; 12 AND ignore_hour &amp;gt; 18|eval month=strftime(_time,"%b")|eval day=strftime(_time,"%d")|eval mod_date=if(ignore_hour&amp;lt;18,day,day=day+1)|stats min(_time) as start,max(_time) as End by Policy,day,month|eval diff=End-start
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Of-course you could tweak a little if there is any mistake OR any better solution can be suggested. Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 16 Aug 2013 09:41:41 GMT</pubDate>
    <dc:creator>linu1988</dc:creator>
    <dc:date>2013-08-16T09:41:41Z</dc:date>
    <item>
      <title>Search buckets span=18h</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37266#M8308</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
I got a complex situation i'll try to explain best as possible:&lt;BR /&gt;
I have some jobs events.&lt;BR /&gt;
I group them by Policy.&lt;BR /&gt;
I do my search from yesterday 18h to today 12h.&lt;BR /&gt;
For each policy, i want the first job started, the last one finished and the interval.&lt;BR /&gt;
This search to it pretty well:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=infra_nb sourcetype=nbjobs|stats min(_time) as start,max(End) as end by Policy|eval diff=end-start
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here comes the troubles : I want the same search to process ,but this time in the past two months,having one result per "day". I need to group my jobs events by packets of 12AM-6PM=18 hours (which is easy with bins), packets starting each day at 6PM.(And this, i didnt find how to process)&lt;BR /&gt;
So for each packets of events i do the previous search. I can then draw the evolution of the interval for each policy in respect to Time.&lt;/P&gt;

&lt;P&gt;A solution would be to run the previous search each day as scheduled task, to store results into Splunk and then draw statistics from them, but i would avoir this if possible.&lt;/P&gt;

&lt;P&gt;Thx for your help,&lt;/P&gt;

&lt;P&gt;EDIT: I search a way to group events in "packets of events", 1packet per "day", but a "day" would be from 6PM to 12AM the next day, (i dont care other events from 12AM to 6PM).&lt;BR /&gt;
In fact i need something like 'bucket spans=18h start=6PM'&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2013 08:30:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37266#M8308</guid>
      <dc:creator>timmalos</dc:creator>
      <dc:date>2013-08-16T08:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Search buckets span=18h</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37267#M8309</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I think it's very hard with the use of earliest and latest to do it for last 2 months. The best way i could think of is like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=infra_nb sourcetype=nbjobs earliest=-2mon@mon latest=@mon|eval ignore_hour=strftime("_time","%H")|where ignore_hour &amp;lt; 12 AND ignore_hour &amp;gt; 18|eval month=strftime(_time,"%b")|eval day=strftime(_time,"%d")|eval mod_date=if(ignore_hour&amp;lt;18,day,day=day+1)|stats min(_time) as start,max(_time) as End by Policy,day,month|eval diff=End-start
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Of-course you could tweak a little if there is any mistake OR any better solution can be suggested. Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2013 09:41:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37267#M8309</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2013-08-16T09:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Search buckets span=18h</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37268#M8310</link>
      <description>&lt;P&gt;I didnt explain well : I dont want one answer for the past two months, i want one answer per day during the past two months (Actually can be 1 or 3 months or even 1 week), but for me a day is not 0am to 12pm but 6pm to 12am if you see what i mean.(Or i just would have used bucket span=24h). I tried using transaction but cant manage to find a good way.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2013 11:40:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37268#M8310</guid>
      <dc:creator>timmalos</dc:creator>
      <dc:date>2013-08-16T11:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Search buckets span=18h</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37269#M8311</link>
      <description>&lt;P&gt;I have updated the answer, Could you please give it a try.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2013 12:21:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37269#M8311</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2013-08-16T12:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Search buckets span=18h</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37270#M8312</link>
      <description>&lt;P&gt;Much better. But now it will calculate stats for events from 0h to 12h and 18h to 24h each day for each Policy.&lt;/P&gt;

&lt;P&gt;What i need is 18h to 24h AND 0h to 12h the day after. All my troubles come from my time window is across two days.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2013 12:54:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37270#M8312</guid>
      <dc:creator>timmalos</dc:creator>
      <dc:date>2013-08-16T12:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: Search buckets span=18h</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37271#M8313</link>
      <description>&lt;P&gt;Did some changes, please give it a try&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2013 13:14:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37271#M8313</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2013-08-16T13:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Search buckets span=18h</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37272#M8314</link>
      <description>&lt;P&gt;Did some changes, here is the final search : index=infra_nb sourcetype=nbjobs |eval hour=strftime(_time,"%H")|search (hour&amp;lt;12)OR(hour&amp;gt;=18)|eval month=strftime(_time,"%b")|eval day=strftime(_time,"%d")|eval day=if(hour&amp;lt;12,day,day+1)|stats min(_time) as start,max(eval(_time+jobElapsedTime)) as End by Policy,day,month|eval diff=End-start&lt;/P&gt;

&lt;P&gt;Thx a lot for your help !&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:35:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-buckets-span-18h/m-p/37272#M8314</guid>
      <dc:creator>timmalos</dc:creator>
      <dc:date>2020-09-28T14:35:59Z</dc:date>
    </item>
  </channel>
</rss>

