<?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: How to Compute Incident Duration Records? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517846#M145635</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/215670"&gt;@Nisha18789&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see. Thanks for the clarification!&lt;/P&gt;</description>
    <pubDate>Fri, 04 Sep 2020 03:17:37 GMT</pubDate>
    <dc:creator>yshen</dc:creator>
    <dc:date>2020-09-04T03:17:37Z</dc:date>
    <item>
      <title>How to Compute Incident Duration Records?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517759#M145607</link>
      <description>&lt;P&gt;I have the following events in Splunk:&lt;/P&gt;&lt;P&gt;_time&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Agent_Hostname&amp;nbsp; &amp;nbsp; &amp;nbsp; alarm&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;status&lt;BR /&gt;2020-08-23T03:04:05.000-0700 m50-ups.a_domain upsAlarmOnBypass raised&lt;BR /&gt;2020-08-23T03:07:16.000-0700 m50-ups.a_domain upsTrapOnBattery raised&lt;BR /&gt;2020-08-23T03:07:16.000-0700 m50-ups.a_domain upsAlarmInputBad raised&lt;BR /&gt;2020-08-23T03:07:39.000-0700 m50-ups.a_domain upsAlarmOnBypass raised&lt;BR /&gt;2020-08-23T03:07:39.000-0700 m50-ups.a_domain upsAlarmLowBattery raised&lt;BR /&gt;2020-08-23T03:08:17.000-0700 m50-ups.a_domain upsTrapOnBattery raised&lt;BR /&gt;2020-08-23T03:09:24.000-0700 m50-ups.a_domain upsTrapOnBattery raised&lt;BR /&gt;2020-08-23T03:10:31.000-0700 m50-ups.a_domain upsAlarmOnBattery cleared&lt;BR /&gt;2020-08-23T03:10:32.000-0700 m50-ups.a_domain upsAlarmInputBad cleared&lt;BR /&gt;2020-08-23T03:11:12.000-0700 m50-ups.a_domain upsAlarmLowBattery cleared&lt;BR /&gt;2020-08-23T03:19:06.000-0700 m50-ups.a_domain upsAlarmInputBad raised&lt;BR /&gt;2020-08-23T03:19:06.000-0700 m50-ups.a_domain upsTrapOnBattery raised&lt;BR /&gt;2020-08-23T03:19:13.000-0700 m50-ups.a_domain upsAlarmLowBattery raised&lt;BR /&gt;2020-08-23T03:20:10.000-0700 m50-ups.a_domain upsTrapOnBattery raised&lt;BR /&gt;2020-08-23T03:21:16.000-0700 m50-ups.a_domain upsTrapOnBattery raised&lt;BR /&gt;2020-08-23T03:22:22.000-0700 m50-ups.a_domain upsTrapOnBattery raised&lt;BR /&gt;2020-08-23T03:23:29.000-0700 m50-ups.a_domain upsTrapOnBattery raised&lt;BR /&gt;2020-08-23T03:24:28.000-0700 m50-ups.a_domain upsAlarmInputBad cleared&lt;BR /&gt;2020-08-23T03:24:28.000-0700 m50-ups.a_domain upsAlarmOnBattery cleared&lt;BR /&gt;2020-08-23T03:25:09.000-0700 m50-ups.a_domain upsAlarmLowBattery cleared&lt;BR /&gt;2020-08-23T03:25:58.000-0700 m50-ups.a_domain upsAlarmOnBypass cleared&lt;/P&gt;&lt;P&gt;My problem is how to compute records of incidents' duration for each host and each alarm type, for example,&lt;BR /&gt;from the above events I'd have the following:&lt;/P&gt;&lt;P&gt;start&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Agent_Hostname&amp;nbsp; &amp;nbsp; &amp;nbsp; alarm&lt;BR /&gt;2020-08-23T03:04:05.000-0700 2020-08-23T03:25:58.000-0700 m50-ups.a_domain upsAlarmOnBypass&lt;BR /&gt;2020-08-23T03:07:16.000-0700 m50-ups.a_domain upsTrapOnBattery&lt;BR /&gt;2020-08-23T03:07:16.000-0700 2020-08-23T03:24:28.000-0700 m50-ups.a_domain upsAlarmInputBad&lt;BR /&gt;2020-08-23T03:07:39.000-0700 2020-08-23T03:25:09.000-0700 m50-ups.a_domain upsAlarmLowBattery&lt;/P&gt;&lt;P&gt;where start is the earliest time when an alarm for a host is first raised, and&lt;BR /&gt;end is the time when the same alarm/host is cleared.&lt;/P&gt;&lt;P&gt;My second problem is how to find the biggest span of duration among those enclosed spans, ignoring those without end time.&lt;/P&gt;&lt;P&gt;My question is how I can achieve within the framework of Splunk?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 16:29:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517759#M145607</guid>
      <dc:creator>yshen</dc:creator>
      <dc:date>2020-09-03T16:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to Compute Incident Duration Records?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517764#M145610</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222699"&gt;@yshen&lt;/a&gt;&amp;nbsp;, for 1st query , table for alarm , host&amp;nbsp; and durations, you can use below query&amp;nbsp;&lt;/P&gt;&lt;P&gt;| makeresults&lt;BR /&gt;| eval start="2020-08-23T03:04:05.000-0700"&lt;BR /&gt;| eval end="2020-08-23T03:25:58.000-0700"&lt;BR /&gt;| eval Agent_hostname="m50-ups.a_domain"&lt;BR /&gt;| eval alarm="upsAlarmOnBypass"&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;&lt;EM&gt;| eval start_epoch=strptime(start,"%Y-%m-%dT%H:%M:%S.000-0700"), end_epoch=strptime(end,"%Y-%m-%dT%H:%M:%S.000-0700")&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;&lt;EM&gt;| eval duration_mins = ROUND((end_epoch - start_epoch)/60,2)&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;&lt;EM&gt;| table Agent_hostname alarm start end duration&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;For 2nd one,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;| makeresults&lt;BR /&gt;| eval start="2020-08-23T03:04:05.000-0700"&lt;BR /&gt;| eval end="2020-08-23T03:25:58.000-0700"&lt;BR /&gt;| eval Agent_hostname="m50-ups.a_domain"&lt;BR /&gt;| eval alarm="upsAlarmOnBypass"&lt;BR /&gt;&lt;FONT color="#800080"&gt;&lt;EM&gt;| search end!=""&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;&lt;EM&gt;| eval start_epoch=strptime(start,"%Y-%m-%dT%H:%M:%S.000-0700"), end_epoch=strptime(end,"%Y-%m-%dT%H:%M:%S.000-0700")&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;&lt;EM&gt;| eval duration_mins = ROUND((end_epoch - start_epoch)/60,2)&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;&lt;EM&gt;| fields - start_epoch end_epoch _time&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;&lt;EM&gt;| table Agent_hostname alarm start end duration_mins&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;&lt;EM&gt;| stats max(duration_mins) as max_duration_mins by Agent_hostname,alarm&lt;/EM&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 17:06:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517764#M145610</guid>
      <dc:creator>Nisha18789</dc:creator>
      <dc:date>2020-09-03T17:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to Compute Incident Duration Records?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517791#M145620</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/215670"&gt;@Nisha18789&lt;/a&gt;&amp;nbsp; Thanks for your help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the first problem, I'm looking for a solution that can compute the start time, end time for each host, and each alarm type. It seems that your suggestion for the first problem is a hard coded one. It would not work with other situation that the start time may not be&amp;nbsp;&lt;SPAN&gt;"2020-08-23T03:04:05.000-0700".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have not fully understood the second part of your suggestion to the 2nd problem, besides the same limitation of hard coding the start and end time. Your solution might work with the hard coding improved.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 18:35:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517791#M145620</guid>
      <dc:creator>yshen</dc:creator>
      <dc:date>2020-09-03T18:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to Compute Incident Duration Records?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517821#M145628</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222699"&gt;@yshen&lt;/a&gt;&amp;nbsp;, the part where I hardcoded is just a run anywhere example.&lt;/P&gt;&lt;P&gt;Please only use the highlighted in violet color part with your existing fields in the log for both the questions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 20:54:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517821#M145628</guid>
      <dc:creator>Nisha18789</dc:creator>
      <dc:date>2020-09-03T20:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to Compute Incident Duration Records?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517846#M145635</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/215670"&gt;@Nisha18789&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see. Thanks for the clarification!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 03:17:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517846#M145635</guid>
      <dc:creator>yshen</dc:creator>
      <dc:date>2020-09-04T03:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to Compute Incident Duration Records?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517939#M145670</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/215670"&gt;@Nisha18789&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I studied in details of your solution. I'm afraid that it does not solve my problems.&lt;/P&gt;&lt;P&gt;Here are my understanding and paraphrase of your proposal:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval start="2020-08-23T03:04:05.000-0700"
| eval end="2020-08-23T03:25:58.000-0700"
| eval Agent_hostname="m50-ups.a_domain"
| eval alarm="upsAlarmOnBypass"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create data fields of start, end, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval start_epoch=strptime(start,"%Y-%m-%dT%H:%M:%S.000-0700"), end_epoch=strptime(end,"%Y-%m-%dT%H:%M:%S.000-0700")
| eval duration_mins = ROUND((end_epoch - start_epoch)/60,2)
| table Agent_hostname alarm start end duration&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;based on the known value of start and end values,&amp;nbsp; compute the duration.&lt;/P&gt;&lt;P&gt;But the key problem of mine is how to find the proper values of the start, and end! This problem is not being&amp;nbsp; addressed by your proposal.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe, I should phrase my question as how to find the earliest start of an alarm and the time when it's being cleared.&lt;/P&gt;&lt;P&gt;Below is my sketch of a solution, it may not be perfect, but I hope to show how the start and end might be computed outside of Splunk:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;;; assume the symbol events is for the events of alarms in chronological order
(as-&amp;gt; (group-by :Agent_Hostname events) ; group the events by Agent_Hostname value
    grouped-host                      
    (map                                ; for each host
     (fn [[host events-host]]
       [host
        (as-&amp;gt; (group-by                 ; group the events by alarm value
               #(alarm-classification (% :alarm)) events-host) grouped-alarm 
          (map                          ; for each alarm
           (fn [[alarm events-alarm]]
             [alarm
              (as-&amp;gt;
                  (partition-by :status ; partition the events by same value of :status
                                events-alarm) x 
                  (map first x) ; only take the first (the earliest) event of the same status)
                  (partition 2 x)      ; combine the start and end events
                  (map start-end x))]) ; add the start and end time of an alarm event
           grouped-alarm)
          )])
     grouped-host))
;; =&amp;gt; (["m50-tc-ups.bart.gov"
;;      (["upsAlarmOnBypass"
;;        ({:start "2020-08-23T03:04:05.000-0700",
;;          :end "2020-08-23T03:25:58.000-0700"})]
;;       ["upsAlarmOnBattery"
;;        ({:start "2020-08-23T03:07:16.000-0700",
;;          :end "2020-08-23T03:10:31.000-0700"}
;;         {:start "2020-08-23T03:19:06.000-0700",
;;          :end "2020-08-23T03:24:28.000-0700"})]
;;       ["upsAlarmInputBad"
;;        ({:start "2020-08-23T03:07:16.000-0700",
;;          :end "2020-08-23T03:10:32.000-0700"}
;;         {:start "2020-08-23T03:19:06.000-0700",
;;          :end "2020-08-23T03:24:28.000-0700"})]
;;       ["upsAlarmLowBattery"
;;        ({:start "2020-08-23T03:07:39.000-0700",
;;          :end "2020-08-23T03:11:12.000-0700"}
;;         {:start "2020-08-23T03:19:13.000-0700",
;;          :end "2020-08-23T03:25:09.000-0700"})])])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 16:33:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517939#M145670</guid>
      <dc:creator>yshen</dc:creator>
      <dc:date>2020-09-04T16:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to Compute Incident Duration Records?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517944#M145674</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222699"&gt;@yshen&lt;/a&gt;&amp;nbsp;, I understand your point now. Try below with your log events&lt;/P&gt;&lt;P&gt;I am assuming your _time field has format like :&amp;nbsp;&lt;SPAN&gt;2020-08-23T03:04:05.000-0700 and it represents the start time in each log event.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;your base search....&lt;BR /&gt;| transaction &lt;SPAN&gt;Agent_Hostname&amp;nbsp;&lt;/SPAN&gt;alarm startswith="raised" endswith="cleared"&lt;BR /&gt;|eval end=_time+duration, start=_time&lt;BR /&gt;|eval end=strftime(end,"%Y-%m-%dT%H:%M:%S.%3N-0700"),start=strftime(start,"%d-%m-%Y %H:%M:%S.%3N-0700")&lt;BR /&gt;| table start,end ,&lt;SPAN&gt;Agent_Hostname , alarm,&lt;/SPAN&gt; duration&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try and let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 17:27:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Compute-Incident-Duration-Records/m-p/517944#M145674</guid>
      <dc:creator>Nisha18789</dc:creator>
      <dc:date>2020-09-04T17:27:09Z</dc:date>
    </item>
  </channel>
</rss>

