<?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 can I get the time difference between two events? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-time-difference-between-two-events/m-p/657254#M227013</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I am looking at logs for asynchronous calls ( sending msg &amp;amp; receiving ack from kafka )&amp;nbsp;. So we have 2 event , first one is when we receive the message and start processing then send it to Kafka , second one is when we receive response back from kafka. I have unique message ID to track both event.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to capture average processing&amp;nbsp;time for all unique ID. In below query I have not added condition for unique ID. in below query I am not getting "Diffrence" value.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can you please help !!&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index=web* "Message sent to Kafka" OR "Response received from Kafka"&lt;BR /&gt;| stats earlies(_time) as Msg_received, latest(_time) as Response_Kafka&lt;BR /&gt;| eval difference=Response_Kafka-Msg_received&lt;BR /&gt;| eval difference=strftime(difference,"%d-%m-%Y %H:%M:%S")&lt;BR /&gt;| eval Msg_received=strftime(Msg_received,"%d-%m-%Y %H:%M:%S")&lt;BR /&gt;| eval Response_Kafka=strftime(Response_Kafka,"%d-%m-%Y %H:%M:%S")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Sep 2023 03:20:23 GMT</pubDate>
    <dc:creator>yuvrajsharma_13</dc:creator>
    <dc:date>2023-09-12T03:20:23Z</dc:date>
    <item>
      <title>How can I get the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-time-difference-between-two-events/m-p/657254#M227013</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am looking at logs for asynchronous calls ( sending msg &amp;amp; receiving ack from kafka )&amp;nbsp;. So we have 2 event , first one is when we receive the message and start processing then send it to Kafka , second one is when we receive response back from kafka. I have unique message ID to track both event.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to capture average processing&amp;nbsp;time for all unique ID. In below query I have not added condition for unique ID. in below query I am not getting "Diffrence" value.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can you please help !!&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index=web* "Message sent to Kafka" OR "Response received from Kafka"&lt;BR /&gt;| stats earlies(_time) as Msg_received, latest(_time) as Response_Kafka&lt;BR /&gt;| eval difference=Response_Kafka-Msg_received&lt;BR /&gt;| eval difference=strftime(difference,"%d-%m-%Y %H:%M:%S")&lt;BR /&gt;| eval Msg_received=strftime(Msg_received,"%d-%m-%Y %H:%M:%S")&lt;BR /&gt;| eval Response_Kafka=strftime(Response_Kafka,"%d-%m-%Y %H:%M:%S")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 03:20:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-time-difference-between-two-events/m-p/657254#M227013</guid>
      <dc:creator>yuvrajsharma_13</dc:creator>
      <dc:date>2023-09-12T03:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-time-difference-between-two-events/m-p/657255#M227014</link>
      <description>&lt;P&gt;Updated Query :&lt;/P&gt;&lt;P&gt;Time difference is coming as "12/31/23 19:00:30:295 "&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index=web* "Message sent to Kafka" OR "Response received from Kafka"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| stats earlies(_time) as Msg_received, latest(_time) as Response_Kafka by Unique_ID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval difference=Response_Kafka-Msg_received&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval difference=strftime(difference,"%d-%m-%Y %H:%M:%S")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Msg_received=strftime(Msg_received,"%d-%m-%Y %H:%M:%S")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Response_Kafka=strftime(Response_Kafka,"%d-%m-%Y %H:%M:%S")&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 03:27:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-time-difference-between-two-events/m-p/657255#M227014</guid>
      <dc:creator>yuvrajsharma_13</dc:creator>
      <dc:date>2023-09-12T03:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-time-difference-between-two-events/m-p/657273#M227022</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/260091"&gt;@yuvrajsharma_13&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;for the difference you have to use the tostring option (&lt;A href="https://docs.splunk.com/Documentation/SCS/current/SearchReference/ConversionFunctions#tostring.28.26lt.3Bvalue.26gt.3B.2C_.26lt.3Bformat.26gt.3B.29" target="_blank"&gt;https://docs.splunk.com/Documentation/SCS/current/SearchReference/ConversionFunctions#tostring.28.26lt.3Bvalue.26gt.3B.2C_.26lt.3Bformat.26gt.3B.29&lt;/A&gt;) and not strftime that is used to convert date format, so please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=web* "Message sent to Kafka" OR "Response received from Kafka"
| stats earlies(_time) as Msg_received, latest(_time) as Response_Kafka by Unique_ID
| eval difference=tostring(Response_Kafka-Msg_received,"duration")
| eval Msg_received=strftime(Msg_received,"%d-%m-%Y %H:%M:%S")
| eval Response_Kafka=strftime(Response_Kafka,"%d-%m-%Y %H:%M:%S")&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 06:27:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-time-difference-between-two-events/m-p/657273#M227022</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-09-12T06:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-time-difference-between-two-events/m-p/657342#M227050</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;, that helped, however now I have to change my query as we are not receiving response for few Unique_ID so difference is showing as 0 seconds.&lt;/P&gt;&lt;P&gt;I am using subsearch for this, so it should capture events for which we received response .&amp;nbsp; Subsearch itself is not returning any results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;After this I need to work on time difference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=web* "Message sent to Kafka" | where UNIQUE_ID IN ( [ search index=web*&amp;nbsp;"Response received from Kafka" | fields UNIQUE_ID ]) | table&amp;nbsp;UNIQUE_ID, _time&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 15:24:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-time-difference-between-two-events/m-p/657342#M227050</guid>
      <dc:creator>yuvrajsharma_13</dc:creator>
      <dc:date>2023-09-12T15:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-time-difference-between-two-events/m-p/657389#M227069</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/260091"&gt;@yuvrajsharma_13&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;as I said, if the issue is that the difference is showed as a date, you can use the tostring option to show in hours, minutes and seconds.&lt;/P&gt;&lt;P&gt;for the missing UNIQUE_ID, you found the solution.&lt;/P&gt;&lt;P&gt;let me know if I can help you more, or, please, accept one answer for the other people of Community.&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>Wed, 13 Sep 2023 06:26:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-time-difference-between-two-events/m-p/657389#M227069</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-09-13T06:26:46Z</dc:date>
    </item>
  </channel>
</rss>

