<?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: Calculate time difference between different events of a table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608677#M211651</link>
    <description>&lt;P&gt;Field names are case-sensitive - try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats window=2 global=f range(_time) as difference by rule_id&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 08 Aug 2022 11:41:49 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2022-08-08T11:41:49Z</dc:date>
    <item>
      <title>How would I calculate time difference between different events of a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608408#M211539</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp; i am using 2 searches combined via an append to get me data in the following format. Each row is a distinct event in Raw data.&lt;/P&gt;
&lt;TABLE border="1" width="76.5625%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;_time&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;Status&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;owner&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;rule_ID&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;&lt;SPAN&gt;2022-08-03 23:00:00&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;&amp;lt;null&amp;gt;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;unassigned&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;001&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;&lt;SPAN&gt;2022-08-03 23:35:00&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;Acknowledged&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;John&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;001&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;&lt;SPAN&gt;2022-08-03 23:40:00&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;Resolved&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;John&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;001&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to calculate time_difference between each event&amp;nbsp; i.e. each row above.&amp;nbsp; How can i get another column called "&lt;STRONG&gt;difference&lt;/STRONG&gt;" added that shows the delta between these 3 different events.&lt;BR /&gt;&lt;BR /&gt;Desired Output:&lt;/P&gt;
&lt;TABLE border="1" width="678.125px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="187.625px" height="25px"&gt;_time&lt;/TD&gt;
&lt;TD width="189.844px" height="25px"&gt;Status&lt;/TD&gt;
&lt;TD width="188.562px" height="25px"&gt;owner&lt;/TD&gt;
&lt;TD width="63.0625px" height="25px"&gt;rule_ID&lt;/TD&gt;
&lt;TD width="48.0312px"&gt;Difference&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187.625px" height="25px"&gt;&lt;SPAN&gt;2022-08-03 23:00:00&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="189.844px" height="25px"&gt;&amp;lt;null&amp;gt;&lt;/TD&gt;
&lt;TD width="188.562px" height="25px"&gt;unassigned&lt;/TD&gt;
&lt;TD width="63.0625px" height="25px"&gt;001&lt;/TD&gt;
&lt;TD width="48.0312px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187.625px" height="25px"&gt;&lt;SPAN&gt;2022-08-03 23:35:00&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="189.844px" height="25px"&gt;Acknowledged&lt;/TD&gt;
&lt;TD width="188.562px" height="25px"&gt;John&lt;/TD&gt;
&lt;TD width="63.0625px" height="25px"&gt;001&lt;/TD&gt;
&lt;TD width="48.0312px"&gt;0:35:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="187.625px" height="25px"&gt;&lt;SPAN&gt;2022-08-03 23:40:00&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="189.844px" height="25px"&gt;Resolved&lt;/TD&gt;
&lt;TD width="188.562px" height="25px"&gt;John&lt;/TD&gt;
&lt;TD width="63.0625px" height="25px"&gt;001&lt;/TD&gt;
&lt;TD width="48.0312px"&gt;0:05:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;BR /&gt;Note:&amp;nbsp; Rule_ID is the only common field in all 3 events. I referred to other posts here where folks have recommended transaction command. Unfortunately i don't have any specific field to use in &lt;STRONG&gt;startswith&lt;/STRONG&gt; or &lt;STRONG&gt;endswith&lt;/STRONG&gt;&amp;nbsp; , so transaction won't work.&lt;BR /&gt;&lt;BR /&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2022 14:37:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608408#M211539</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-08-05T14:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference between different events of a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608421#M211543</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats window=2 global=f range(_time) as difference by rule_ID
| fieldformat difference=tostring(difference,"duration")&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 05 Aug 2022 11:34:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608421#M211543</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-08-05T11:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference between different events of a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608675#M211649</link>
      <description>&lt;P&gt;No luck.&amp;nbsp; The difference column is blank.&amp;nbsp; Here is the query&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| `incident_review`
| where _time &amp;gt; relative_time(now(),"-7d@d") 
| search rule_id=353EA38E-CBD0-4D90-9EDA-B15D16089D17@@notable@@0fb5ae992e6da8629c0a67596540bf58
| eval status_time=strftime(_time,"%Y-%m-%d %H:%M:%S")
| streamstats window=2 global=f range(_time) as difference by rule_ID
| fieldformat difference=tostring(difference,"duration") 
| table  status_time difference rule_id rule_name owner user status_label&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Result&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="neerajs_81_0-1659957724212.png" style="width: 693px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20932i78F7C28AB4039274/image-dimensions/693x349?v=v2" width="693" height="349" role="button" title="neerajs_81_0-1659957724212.png" alt="neerajs_81_0-1659957724212.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2022 11:22:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608675#M211649</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-08-08T11:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference between different events of a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608677#M211651</link>
      <description>&lt;P&gt;Field names are case-sensitive - try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats window=2 global=f range(_time) as difference by rule_id&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 08 Aug 2022 11:41:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608677#M211651</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-08-08T11:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference between different events of a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608689#M211653</link>
      <description>&lt;P&gt;If you strftime your timestamp to a string, you can't calculate anything anymore on it because it's a string now. You'd have to strptime it back to a epoch-based timestamp which is a bit pointless. Use fieldformat instead of eval to display your status_time in a human-readable way but keep it internally as a unix timestamp.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2022 13:13:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608689#M211653</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-08-08T13:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference between different events of a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608771#M211676</link>
      <description>&lt;P&gt;That worked.&amp;nbsp; Awesome !!.&amp;nbsp; But curious, how did it work even though i am doing the following in the line above your&amp;nbsp; streamstats command ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eval status_time=strftime(_time,"%Y-%m-%d %H:%M:%S") &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If you notice PickeRick's comment above, status_time should be in epoch format for us to calculate the difference.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 05:48:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608771#M211676</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-08-09T05:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference between different events of a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608781#M211682</link>
      <description>&lt;P&gt;PickleRick's comment is wrong&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eval status_time=strftime(_time,"%Y-%m-%d %H:%M:%S")&lt;/LI-CODE&gt;&lt;P&gt;does not change the _time field, it creates a new field called status_time, and therefore has no effect on the calculations based on the _time field&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 06:34:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608781#M211682</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-08-09T06:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference between different events of a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608786#M211687</link>
      <description>&lt;P&gt;You're right. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I noticed the strftime but didn't notice that the range() was operating on _time, not on that strftimed field.&lt;/P&gt;&lt;P&gt;My original comments holds valid but is just not applicable in this case &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 07:22:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608786#M211687</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-08-09T07:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference between different events of a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608804#M211694</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;. I have given you karma points.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 07:56:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-I-calculate-time-difference-between-different-events/m-p/608804#M211694</guid>
      <dc:creator>neerajs_81</dc:creator>
      <dc:date>2022-08-09T07:56:43Z</dc:date>
    </item>
  </channel>
</rss>

