<?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 calculate individual fail time? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-individual-fail-time/m-p/668388#M229299</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I have following data:&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:00:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:00:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:05:00 Item=A Result=fail &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:05:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:10:00 Item=A Result=fail &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:10:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:15:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:15:05 Item=B Result=fail &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:20:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:20:05 Item=B Result=fail &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:25:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:25:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:30:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:30:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:35:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:35:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:40:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:40:05 Item=B Result=fail &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:45:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:45:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:50:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:50:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:55:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:55:05 Item=B Result=success&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;My desired results:&lt;BR /&gt;&lt;FONT color="#993366"&gt;Item StartTime EndTime Duration &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993366"&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02:05:00&amp;nbsp; &amp;nbsp; 02:15:00 00:10:00&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993366"&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02:15:05&amp;nbsp; &amp;nbsp; 02:25:05 00:10:00&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993366"&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02:40:05&amp;nbsp; &amp;nbsp; 02:45:05 00:05:00&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;I had tried &lt;STRONG&gt;transaction&lt;/STRONG&gt; and &lt;STRONG&gt;streamstats&lt;/STRONG&gt; but got wrong results.&lt;BR /&gt;Can anybody here help me to solve this problem?&lt;BR /&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Nov 2023 07:08:42 GMT</pubDate>
    <dc:creator>WK</dc:creator>
    <dc:date>2023-11-13T07:08:42Z</dc:date>
    <item>
      <title>How to calculate individual fail time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-individual-fail-time/m-p/668388#M229299</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have following data:&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:00:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:00:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:05:00 Item=A Result=fail &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:05:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:10:00 Item=A Result=fail &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:10:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:15:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:15:05 Item=B Result=fail &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:20:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:20:05 Item=B Result=fail &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:25:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:25:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:30:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:30:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:35:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:35:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:40:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:40:05 Item=B Result=fail &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:45:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:45:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:50:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:50:05 Item=B Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:55:00 Item=A Result=success &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;02:55:05 Item=B Result=success&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;My desired results:&lt;BR /&gt;&lt;FONT color="#993366"&gt;Item StartTime EndTime Duration &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993366"&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02:05:00&amp;nbsp; &amp;nbsp; 02:15:00 00:10:00&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993366"&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02:15:05&amp;nbsp; &amp;nbsp; 02:25:05 00:10:00&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993366"&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02:40:05&amp;nbsp; &amp;nbsp; 02:45:05 00:05:00&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;I had tried &lt;STRONG&gt;transaction&lt;/STRONG&gt; and &lt;STRONG&gt;streamstats&lt;/STRONG&gt; but got wrong results.&lt;BR /&gt;Can anybody here help me to solve this problem?&lt;BR /&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 07:08:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-individual-fail-time/m-p/668388#M229299</guid>
      <dc:creator>WK</dc:creator>
      <dc:date>2023-11-13T07:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculated individual fail time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-individual-fail-time/m-p/668391#M229300</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/262416"&gt;@WK&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;what's the condition fro grouping?&lt;/P&gt;&lt;P&gt;How can I recognize StartTime and EndTime?&lt;/P&gt;&lt;P&gt;this is one of the few situation where to use the transactin command.&lt;/P&gt;&lt;P&gt;if you want to trace when there's a Fail and a following Success, you could try somethin like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt;
| transaction Item StartsWith="Result=Fail" EndsWith="Result=Success"
| eval 
   StartTime=strftime(_time,"%H:%M:%S),
   EndTime=strftime(_time+duration,"%H:%M:%S), 
   Duration=tostring(duration,"duration")
| table Item StartTime EndTime Duration&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 07:14:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-individual-fail-time/m-p/668391#M229300</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-11-13T07:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculated individual fail time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-individual-fail-time/m-p/668393#M229301</link>
      <description>&lt;P&gt;Thanks for your swift response.&lt;BR /&gt;I need to calculate the duration between first "fail" to first "success" for every Item.&lt;BR /&gt;Unfortunately the result is incorrect:&lt;BR /&gt;&lt;FONT color="#993366"&gt;Item StartTime EndTime Duration&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993366"&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02:40:05 02:45:05 00:05:00&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02:20:05 02:25:05 00:05:00&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02:15:05 02:30:05 00:15:00&amp;nbsp; &amp;nbsp; &amp;nbsp;==&amp;gt; should be "B&amp;nbsp; 02:15:05 02:25:05 00:10:00"&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02:10:00 02:15:00 00:05:00&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02:05:00 02:20:00 00:15:00&amp;nbsp; &amp;nbsp; &amp;nbsp;==&amp;gt; should be "A&amp;nbsp; 02:05:00 02:15:00 00:10:00"&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I'd tried this method before, however consecutive "Result=fail" causes overlapped results.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 07:30:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-individual-fail-time/m-p/668393#M229301</guid>
      <dc:creator>WK</dc:creator>
      <dc:date>2023-11-13T07:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculated individual fail time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-individual-fail-time/m-p/668461#M229322</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;'s answer should give you the desired output. &amp;nbsp;Is it possible that some events come out of order? &amp;nbsp;You can use sort to make sure events are in perfect revere time order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| sort - _time
| transaction Item startswith="Result=fail" endswith="Result=success"
| eval EndTime = _time + duration
| fieldformat EndTime = strftime(EndTime, "%F %T")
| fieldformat duration = tostring(duration, "duration")
| fields Item _time EndTime duration&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here you can rename _time as StartTime if you wish, then format it for display. &amp;nbsp;For large number of events, sort can be expensive. &amp;nbsp;This is one of the costs of transaction when raw events are not perfectly in order.&lt;/P&gt;&lt;P&gt;Here is an emulation you can play with and compare with raw data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval data = split("02:00:00 Item=A Result=success
02:00:05 Item=B Result=success
02:05:00 Item=A Result=fail
02:05:05 Item=B Result=success
02:10:00 Item=A Result=fail
02:10:05 Item=B Result=success
02:15:00 Item=A Result=success
02:15:05 Item=B Result=fail
02:20:00 Item=A Result=success
02:20:05 Item=B Result=fail
02:25:00 Item=A Result=success
02:25:05 Item=B Result=success
02:30:00 Item=A Result=success
02:30:05 Item=B Result=success
02:35:00 Item=A Result=success
02:35:05 Item=B Result=success
02:40:00 Item=A Result=success
02:40:05 Item=B Result=fail
02:45:00 Item=A Result=success
02:45:05 Item=B Result=success
02:50:00 Item=A Result=success
02:50:05 Item=B Result=success
02:55:00 Item=A Result=success
02:55:05 Item=B Result=success", "
")
| mvexpand data
| rename data as _raw
| rex "^(?&amp;lt;_time&amp;gt;\S+)"
| eval _time = strptime(_time, "%H:%M:%S")
| extract
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Combining the two, I get&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Item&lt;/TD&gt;&lt;TD&gt;_time&lt;/TD&gt;&lt;TD&gt;EndTime&lt;/TD&gt;&lt;TD&gt;duration&lt;/TD&gt;&lt;TD&gt;_raw&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;2023-11-13 02:40:05&lt;/TD&gt;&lt;TD&gt;2023-11-13 02:45:05&lt;/TD&gt;&lt;TD&gt;00:05:00&lt;/TD&gt;&lt;TD&gt;02:40:05 Item=B Result=fail 02:45:05 Item=B Result=success&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;2023-11-13 02:20:05&lt;/TD&gt;&lt;TD&gt;2023-11-13 02:25:05&lt;/TD&gt;&lt;TD&gt;00:05:00&lt;/TD&gt;&lt;TD&gt;02:20:05 Item=B Result=fail 02:25:05 Item=B Result=success&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;2023-11-13 02:15:05&lt;/TD&gt;&lt;TD&gt;2023-11-13 02:30:05&lt;/TD&gt;&lt;TD&gt;00:15:00&lt;/TD&gt;&lt;TD&gt;02:15:05 Item=B Result=fail 02:30:05 Item=B Result=success&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2023-11-13 02:10:00&lt;/TD&gt;&lt;TD&gt;2023-11-13 02:15:00&lt;/TD&gt;&lt;TD&gt;00:05:00&lt;/TD&gt;&lt;TD&gt;02:10:00 Item=A Result=fail 02:15:00 Item=A Result=success&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2023-11-13 02:05:00&lt;/TD&gt;&lt;TD&gt;2023-11-13 02:20:00&lt;/TD&gt;&lt;TD&gt;00:15:00&lt;/TD&gt;&lt;TD&gt;02:05:00 Item=A Result=fail 02:20:00 Item=A Result=success&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 13 Nov 2023 17:46:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-individual-fail-time/m-p/668461#M229322</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-11-13T17:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculated individual fail time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-individual-fail-time/m-p/668491#M229332</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for your response.&lt;BR /&gt;&lt;SPAN&gt;My desired results:&lt;/SPAN&gt;&lt;BR /&gt;&lt;FONT color="#993366"&gt;Item StartTime EndTime Duration&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993366"&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02:05:00&amp;nbsp; &amp;nbsp; 02:15:00 00:10:00&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993366"&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02:15:05&amp;nbsp; &amp;nbsp; 02:25:05 00:10:00&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993366"&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02:40:05&amp;nbsp; &amp;nbsp; 02:45:05 00:05:00&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I had tried similar methods like your but got wrong results.&lt;BR /&gt;&lt;STRONG&gt;Fail duration&lt;/STRONG&gt; should be calculated &lt;FONT color="#808000"&gt;from first fail to first success&lt;/FONT&gt;.&lt;BR /&gt;Thus actual record count should be 3 instead of 5.&lt;BR /&gt;Sorting may not be the root cause for my question.&lt;/P&gt;&lt;P&gt;It seems that if there are 2 "fail" events, "&lt;STRONG&gt;transaction&lt;/STRONG&gt;" commands generates 2 overlapped records.&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; 02:20:05(fail)&amp;nbsp; &amp;nbsp; &amp;nbsp;02:25:05(success)&amp;nbsp; 00:05:00&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; 02:15:05(fail)&amp;nbsp; &amp;nbsp; &amp;nbsp;02:30:05(success)&amp;nbsp; 00:15:00&lt;/FONT&gt;&lt;BR /&gt;Time duration of first one is included in second one.&lt;BR /&gt;02:30:05(success) should not be considered as the end of fail event.&lt;BR /&gt;02:25:05(success) is the correct one.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2023 02:45:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-individual-fail-time/m-p/668491#M229332</guid>
      <dc:creator>WK</dc:creator>
      <dc:date>2023-11-14T02:45:27Z</dc:date>
    </item>
  </channel>
</rss>

