<?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 calculate time difference between two different searches for a common field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-between-two-different-searches/m-p/634078#M220221</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;..i used a modified version of this and it worked.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2023 16:06:27 GMT</pubDate>
    <dc:creator>akidua</dc:creator>
    <dc:date>2023-03-10T16:06:27Z</dc:date>
    <item>
      <title>How to calculate time difference between two different searches for a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-between-two-different-searches/m-p/633457#M220043</link>
      <description>&lt;P&gt;I have 2 different search queries and I want to calculate sum of differences between time of event 1 and event 2 (in hours) for a common field (customID)&lt;BR /&gt;&lt;BR /&gt;Query 1:&lt;BR /&gt;index=xacin sourcetype="xaxd" "*Completed setting deactivation timer for*" OR "grace period" | rex "[cC]ustom:(?&amp;lt;customID&amp;gt;\w+)"| dedup customID| eval ltime=_time&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;customID&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;ltime&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;wj&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;1678118565.572&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;bi8m&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;1678089668.915&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;nri&lt;/TD&gt;&lt;TD height="25px"&gt;1678060951.505&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Query 2:&lt;BR /&gt;index=xacin sourcetype="xaxd" "*StatusHandler - Completed moving *" | rex "custom:(?&amp;lt;customID&amp;gt;\w+)"| dedup customID |eval rtime=_time&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;customID&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;rtime&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;bi8m&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;1678118477.707&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;a2su&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;1678118456.775&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;ceo&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;1678118425.484&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;nri&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;1678089748.844&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Since bi8m and nri are common customID, I need to output : (1678118477.707-1678089668.915) + (1678089748.844 -1678060951.505) =&amp;nbsp;&lt;SPAN&gt;57606.131&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;I tried to come up with the following query but clearly it's not working:&lt;BR /&gt;&lt;BR /&gt;index=xacin sourcetype="xaxd" "*Completed setting deactivation timer for*" OR "grace period" | rex "[cC]ustom:(?&amp;lt;customID&amp;gt;\w+) "| dedup customID| eval ltime=_time | append [search index=xacin sourcetype="xaxd" "*StatusHandler - Completed moving *" | rex "custom:(?&amp;lt;customID&amp;gt;\w+)"| dedup customID| eval rtime=_time | stats count by customID | where count &amp;gt; 1 |&amp;nbsp;eval time_diff=(rtime-ltime)| stats sum(time_diff)&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 18:16:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-between-two-different-searches/m-p/633457#M220043</guid>
      <dc:creator>akidua</dc:creator>
      <dc:date>2023-03-06T18:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate time difference between two different searches for a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-between-two-different-searches/m-p/633459#M220044</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254508"&gt;@akidua&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you could try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=xacin sourcetype="xaxd" ("*Completed setting deactivation timer for*" OR "grace period" OR "*StatusHandler - Completed moving *"
| rex "[cC]ustom:(?&amp;lt;customID&amp;gt;\w+)"
| rex "custom:(?&amp;lt;customID&amp;gt;\w+)"
| eval 
  rtime=if(searchmatch(like(("%StatusHandler - Completed moving %"),_time,""),
  ltime=if(searchmatch(like(("%StatusHandler - Completed moving %"),"",_time)
| stats earliest(rtime) AS rtime latest(ltime) AS latest count BY customID 
| where count &amp;gt; 1 
| eval time_diff=(rtime-ltime)
| stats sum(time_diff)&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 17:46:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-between-two-different-searches/m-p/633459#M220044</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-03-06T17:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate time difference between two different searches for a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-between-two-different-searches/m-p/634078#M220221</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;..i used a modified version of this and it worked.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 16:06:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-between-two-different-searches/m-p/634078#M220221</guid>
      <dc:creator>akidua</dc:creator>
      <dc:date>2023-03-10T16:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate time difference between two different searches for a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-between-two-different-searches/m-p/634120#M220250</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254508"&gt;@akidua&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Mar 2023 07:07:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-time-difference-between-two-different-searches/m-p/634120#M220250</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-03-11T07:07:17Z</dc:date>
    </item>
  </channel>
</rss>

