<?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 How to read different time slots from lookup table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-read-different-time-slots-from-lookup-table/m-p/485992#M135972</link>
    <description>&lt;P&gt;Hi splunkers,&lt;/P&gt;

&lt;P&gt;I have a situation to read different operational hours of same bin size for the last 3 days&lt;/P&gt;

&lt;P&gt;Scenario:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;                       9-10    10-11  11-12  12-13 13-14  14-15   15-16 .............23-24
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Today                 1        2           3     4       5&lt;BR /&gt;
1 day before      1      2        3      4    5&lt;BR /&gt;
2 day before       1        2      3    4     5&lt;BR /&gt;&lt;BR /&gt;
3 day before    1     2        3      4                   5&lt;/P&gt;

&lt;P&gt;As per Today's train scedule it will start at 10 operates till 12 after that it will take some rest and start again at 1 pm. Example: if today the train is in 1st hour of operation, i need to to count the alarmopened in 1st hour of operation for the last 3 days, divide it be 3 to compute average. If today's count of alarm opened is greater than the average, it will give alerts. The same happens for all hours of operation. &lt;/P&gt;

&lt;P&gt;Question: My problem is how can I take the same time slot of previous last 3 days. If Now my train in 2nd hour of operation, how can I get the 2nd hour of operation for the last 3 days&lt;/P&gt;

&lt;P&gt;Note: Bin size is same&lt;BR /&gt;
      everyday running for 5 hours &lt;/P&gt;

&lt;P&gt;TIA&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2019 02:34:53 GMT</pubDate>
    <dc:creator>hanikawadhwa</dc:creator>
    <dc:date>2019-11-16T02:34:53Z</dc:date>
    <item>
      <title>How to read different time slots from lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-read-different-time-slots-from-lookup-table/m-p/485992#M135972</link>
      <description>&lt;P&gt;Hi splunkers,&lt;/P&gt;

&lt;P&gt;I have a situation to read different operational hours of same bin size for the last 3 days&lt;/P&gt;

&lt;P&gt;Scenario:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;                       9-10    10-11  11-12  12-13 13-14  14-15   15-16 .............23-24
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Today                 1        2           3     4       5&lt;BR /&gt;
1 day before      1      2        3      4    5&lt;BR /&gt;
2 day before       1        2      3    4     5&lt;BR /&gt;&lt;BR /&gt;
3 day before    1     2        3      4                   5&lt;/P&gt;

&lt;P&gt;As per Today's train scedule it will start at 10 operates till 12 after that it will take some rest and start again at 1 pm. Example: if today the train is in 1st hour of operation, i need to to count the alarmopened in 1st hour of operation for the last 3 days, divide it be 3 to compute average. If today's count of alarm opened is greater than the average, it will give alerts. The same happens for all hours of operation. &lt;/P&gt;

&lt;P&gt;Question: My problem is how can I take the same time slot of previous last 3 days. If Now my train in 2nd hour of operation, how can I get the 2nd hour of operation for the last 3 days&lt;/P&gt;

&lt;P&gt;Note: Bin size is same&lt;BR /&gt;
      everyday running for 5 hours &lt;/P&gt;

&lt;P&gt;TIA&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2019 02:34:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-read-different-time-slots-from-lookup-table/m-p/485992#M135972</guid>
      <dc:creator>hanikawadhwa</dc:creator>
      <dc:date>2019-11-16T02:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to read different time slots from lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-read-different-time-slots-from-lookup-table/m-p/485993#M135973</link>
      <description>&lt;P&gt;It seems to me that the &lt;CODE&gt;lookup table&lt;/CODE&gt; is irrelevant.  Let us assume that your &lt;CODE&gt;alarms&lt;/CODE&gt; data has a valid &lt;CODE&gt;_time&lt;/CODE&gt; and &lt;CODE&gt;ASSET_NAME&lt;/CODE&gt; value.  If so, you can do what you asked like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults
| eval _raw = "sourcetype,ASSET_NAME,DateTime
Alarm,A,2019-10-26T08:01:01
Alarm,A,2019-10-26T08:02:02
Alarm,A,2019-11-02T08:01:01
Alarm,A,2019-11-02T08:02:02
Alarm,A,2019-11-09T08:01:01
Alarm,A,2019-11-09T08:02:02
Alarm,A,2019-11-16T08:01:01
Alarm,A,2019-11-16T08:02:02
Alarm,A,2019-11-16T08:02:03
Alarm,A,2019-11-16T08:02:04"
| multikv forceheader=1 
| eval _time = strptime(DateTime, "%Y-%m-%dT%H:%M:%S")

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| eval DayOfWeek = strftime(_time, "%a")
| eval HourOfOperation = tonumber(strftime(_time, "%H")) - 7
| eval week = _time
| bin week span=1w
| stats count AS alarms max(_time) AS _time BY ASSET_NAME HourOfOperation DayOfWeek week
| tail 4
| multireport
[ tail 3 | stats avg(alarms) AS alarm_threshold BY ASSET_NAME HourOfOperation ]
[ head 1 ]
| selfjoin ASSET_NAME HourOfOperation
| where alarms &amp;gt; alarm_threshold
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 20:41:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-read-different-time-slots-from-lookup-table/m-p/485993#M135973</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-18T20:41:36Z</dc:date>
    </item>
  </channel>
</rss>

