<?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: Dividing a field with time into 2 hour slots to find matching events in each slot in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392148#M114133</link>
    <description>&lt;P&gt;my Query  and results&lt;BR /&gt;
&lt;CODE&gt;| inputlookup test&lt;BR /&gt;
| fields Category,Time &lt;BR /&gt;
| eval Time= strptime(Time, "%Y-%m-%d %H:%M:%S") &lt;BR /&gt;
| where Time&amp;gt;=relative_time(now(),"-1d") &lt;BR /&gt;
| eval c_time=strftime(Time,"%F %T")&lt;BR /&gt;
&lt;/CODE&gt;:&lt;/P&gt;

&lt;P&gt;Results are like this:&lt;/P&gt;

&lt;P&gt;Category    Time    c_time&lt;BR /&gt;
1   APPLE   1526434675.000000   2018-05-16 11:37:55&lt;BR /&gt;
2   APPLE   1526451005.000000   2018-05-16 16:10:05&lt;BR /&gt;
3   APPLE   1526448470.000000   2018-05-16 15:27:50&lt;BR /&gt;
4   Banana  1526466669.000000   2018-05-16 20:31:09&lt;BR /&gt;
5   Mango   1526438117.000000   2018-05-16 12:35:17&lt;BR /&gt;
6   Mango   1526443223.000000   2018-05-16 14:00:23&lt;/P&gt;</description>
    <pubDate>Thu, 17 May 2018 01:39:23 GMT</pubDate>
    <dc:creator>bharathdoitnow</dc:creator>
    <dc:date>2018-05-17T01:39:23Z</dc:date>
    <item>
      <title>Dividing a field with time into 2 hour slots to find matching events in each slot</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392144#M114129</link>
      <description>&lt;P&gt;Hi splunkers,&lt;/P&gt;

&lt;P&gt;I am trying to solve an use case where I have to monitor some events occurance for every two hours. we have a input lookup which stores info like below:&lt;/P&gt;

&lt;P&gt;Category    Time&lt;BR /&gt;
1   mango   2018-05-07 20:00:44&lt;BR /&gt;
2   Apple   2018-05-07 14:58:04&lt;BR /&gt;
3   Apple   2018-05-07 14:58:04&lt;BR /&gt;
4   Apple   2018-05-07 14:58:04&lt;BR /&gt;
5   Apple   2018-05-04 17:23:55&lt;BR /&gt;
6   Orange  2018-05-08 18:21:16&lt;/P&gt;

&lt;P&gt;I am trying to break the Time value into 2 hours slots and then check if apple,mango or orange exists within that slot. I tried to use splunk inbuilt timeline views but it did not help me to get a time table view like below:&lt;/P&gt;

&lt;P&gt;today&lt;BR /&gt;&lt;BR /&gt;
    &lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4943iDF7F423E753E3B84/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;8-10 AM   10-12PM 12-2PM  2-4PM   4-6PM&lt;BR /&gt;
Apple   yes no  no  yes no&lt;BR /&gt;
orange  no  yes no  yes no&lt;BR /&gt;
Mango   yes yes no  no  no&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4944i4153AF36714B3550/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 04:48:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392144#M114129</guid>
      <dc:creator>bharathdoitnow</dc:creator>
      <dc:date>2018-05-16T04:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dividing a field with time into 2 hour slots to find matching events in each slot</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392145#M114130</link>
      <description>&lt;P&gt;@bharathdoitnow will you have at-least one fruit in all two hour slots? If not can the slot be removed? Also is it only for one day or can it span more than one day? How would the layout look like in that case? (Your data seems to be from multiple days).&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 09:48:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392145#M114130</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-16T09:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dividing a field with time into 2 hour slots to find matching events in each slot</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392146#M114131</link>
      <description>&lt;P&gt;How's this?&lt;BR /&gt;
I think that it is good to keep _time because slot is difficult to edit.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your search)
|timechart span=2h sum(count) as exist by fruit
|fillnull value=0
|untable _time fruit exist
|eval exist=if(exist=0,"no","yes")
|eval slot=strftime(relative_time(_time,"-2h@h"),"%H")+"-"+strftime(_time,"%H")
|xyseries  fruit slot exist
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 May 2018 10:06:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392146#M114131</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2018-05-16T10:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Dividing a field with time into 2 hour slots to find matching events in each slot</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392147#M114132</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt; we may not have at least one fruit every hour, for example if Apple is present between 8-10 i want mark it as available. if apple is not present during 10-12 window, I want to mark it as "Not available" and create an alret to place a order for apple. in similar way i have 6 different fruits which i have to monitor for "today" with 2 hour slots from 8AM to 10PM with an option to check previous days information.&lt;/P&gt;

&lt;P&gt;I am unable to use "_time" feature as it is inputlookup which is having a field containing Time. So even if I apply a time picker for last 60 minutes, it will keep showing information of all previous days so I have to put a filter withing the Time field to pick only for the current date which is a string but in the [2018-05-07 20:00:44] YYYY-MM-DD hh:mm:ss sequence.&lt;/P&gt;

&lt;P&gt;Current Query:&lt;BR /&gt;
| inputlookup test&lt;BR /&gt;
| fields Category,Time &lt;BR /&gt;
| eval Time= strptime(Time, "%Y-%m-%d %H:%M:%S") &lt;BR /&gt;
| where Time&amp;gt;=relative_time(now(),"-1d") &lt;BR /&gt;
| eval c_time=strftime(Time,"%F %T")&lt;/P&gt;

&lt;P&gt;Results:&lt;BR /&gt;
Category    Time    c_time&lt;BR /&gt;
1   APPLE   1526434675.000000   2018-05-16 11:37:55&lt;BR /&gt;
2   APPLE   1526451005.000000   2018-05-16 16:10:05&lt;BR /&gt;
3   APPLE   1526448470.000000   2018-05-16 15:27:50&lt;BR /&gt;
4   Banana  1526466669.000000   2018-05-16 20:31:09&lt;BR /&gt;
5   Mango   1526438117.000000   2018-05-16 12:35:17&lt;BR /&gt;
6   Mango   1526443223.000000   2018-05-16 14:00:23&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:33:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392147#M114132</guid>
      <dc:creator>bharathdoitnow</dc:creator>
      <dc:date>2020-09-29T19:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dividing a field with time into 2 hour slots to find matching events in each slot</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392148#M114133</link>
      <description>&lt;P&gt;my Query  and results&lt;BR /&gt;
&lt;CODE&gt;| inputlookup test&lt;BR /&gt;
| fields Category,Time &lt;BR /&gt;
| eval Time= strptime(Time, "%Y-%m-%d %H:%M:%S") &lt;BR /&gt;
| where Time&amp;gt;=relative_time(now(),"-1d") &lt;BR /&gt;
| eval c_time=strftime(Time,"%F %T")&lt;BR /&gt;
&lt;/CODE&gt;:&lt;/P&gt;

&lt;P&gt;Results are like this:&lt;/P&gt;

&lt;P&gt;Category    Time    c_time&lt;BR /&gt;
1   APPLE   1526434675.000000   2018-05-16 11:37:55&lt;BR /&gt;
2   APPLE   1526451005.000000   2018-05-16 16:10:05&lt;BR /&gt;
3   APPLE   1526448470.000000   2018-05-16 15:27:50&lt;BR /&gt;
4   Banana  1526466669.000000   2018-05-16 20:31:09&lt;BR /&gt;
5   Mango   1526438117.000000   2018-05-16 12:35:17&lt;BR /&gt;
6   Mango   1526443223.000000   2018-05-16 14:00:23&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 01:39:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392148#M114133</guid>
      <dc:creator>bharathdoitnow</dc:creator>
      <dc:date>2018-05-17T01:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Dividing a field with time into 2 hour slots to find matching events in each slot</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392149#M114134</link>
      <description>&lt;P&gt;I tried but unable to use _time as the field shows blank and I had to convert my Inputlook fields which has time string and use. i got stuck here at the moment. Thank you&lt;/P&gt;

&lt;P&gt;| inputlookup test&lt;BR /&gt;
| fields Category,Time &lt;BR /&gt;
| eval Time= strptime(Time, "%Y-%m-%d %H:%M:%S") &lt;BR /&gt;
| where Time&amp;gt;=relative_time(now(),"-1d") &lt;BR /&gt;
| eval c_time=strftime(Time,"%F %T")&lt;/P&gt;

&lt;P&gt;Category    Time    c_time&lt;BR /&gt;
1   APPLE   1526434675.000000   2018-05-16 11:37:55&lt;BR /&gt;
2   APPLE   1526451005.000000   2018-05-16 16:10:05&lt;BR /&gt;
3   APPLE   1526448470.000000   2018-05-16 15:27:50&lt;BR /&gt;
4   Banana  1526466669.000000   2018-05-16 20:31:09&lt;BR /&gt;
5   Mango   1526438117.000000   2018-05-16 12:35:17&lt;BR /&gt;
6   Mango   1526443223.000000   2018-05-16 14:00:23&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:33:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dividing-a-field-with-time-into-2-hour-slots-to-find-matching/m-p/392149#M114134</guid>
      <dc:creator>bharathdoitnow</dc:creator>
      <dc:date>2020-09-29T19:33:55Z</dc:date>
    </item>
  </channel>
</rss>

