<?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 in two different logs in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274096#M82668</link>
    <description>&lt;P&gt;Noticed a problem with the search results. It turns out it's possible to have the same thread-id in on multiple servers. For example [Thread-216189] can be in UNITED_Send.log / UNITED_Receive.log on HOST WASAPP07 or WASAPP08 or WASAPP09. How do I get it to not calculate across the hosts?&lt;/P&gt;

&lt;P&gt;Search String:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=hdx_payer source="/hdx2/was70-32/AppServer/profiles/AppSrv01/logs/PRD2_PY0/UNITED_Receive.log" OR source="/hdx2/was70-32/AppServer/profiles/AppSrv01/logs/PRD2_PY0/UNITED_Send.log" | eval Time=_time | stats values(Time) as Time by thread_id | where mvcount(Time)=2 | eval response_time=tonumber(mvindex(Time,1))-tonumber(mvindex(Time,0)) | convert ctime(Time)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 10:23:49 GMT</pubDate>
    <dc:creator>cj039165</dc:creator>
    <dc:date>2020-09-29T10:23:49Z</dc:date>
    <item>
      <title>Calculate time difference in two different logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274087#M82659</link>
      <description>&lt;P&gt;Hello -&lt;/P&gt;

&lt;P&gt;Stumped on this. I have two different log files. One logs the time (and data) in transactions sent, the other has the time (and data) received. I would like to calculate the 'response' time. From there we could could alert if it goes above a set period of time. Each transactions is link between the two logs via a thread id. I've very new to Splunk, any help would be great.&lt;/P&gt;

&lt;P&gt;Log example Send:&lt;BR /&gt;
10:31:55,462 DEBUG  [Thread-216189] &lt;/P&gt;

&lt;P&gt;Log example Receive:&lt;BR /&gt;
10:32:03,067 DEBUG  [Thread-216189] &lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 14:34:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274087#M82659</guid>
      <dc:creator>cj039165</dc:creator>
      <dc:date>2016-07-19T14:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference in two different logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274088#M82660</link>
      <description>&lt;P&gt;Try like this (check the field name)&lt;BR /&gt;
&lt;STRONG&gt;Updated&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(base search for log 1 - transaction sent ) OR (base search for log 2 - transaction received) | stats values(_time) as Time by thread_id | where mvcount(Time)=2 | eval response_time=tonumber(mvindex(Time,1))-tonumber(mvindex(Time,0)) | convert ctime(Time)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If above still doesn't work, try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(base search for log 1 - transaction sent ) OR (base search for log 2 - transaction received) | eval Time=_time | stats values(Time) as Time by thread_id | where mvcount(Time)=2 | eval response_time=tonumber(mvindex(Time,1))-tonumber(mvindex(Time,0)) | convert ctime(Time)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jul 2016 15:48:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274088#M82660</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-07-19T15:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference in two different logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274089#M82661</link>
      <description>&lt;P&gt;Hello. Thanks for the response. I ran the following search. I'm getting the following error:  Error in 'eval' command: Typechecking failed. '-' only takes numbers.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="/hdx2/was70-32/AppServer/profiles/AppSrv01/logs/PRD2_PY0/KAPE_Receive.log" OR source="/hdx2/was70-32/AppServer/profiles/AppSrv01/logs/PRD2_PY0/KAPE_Send.log" | stats values(_time) as Time by thread_id | where mvcount(Time)=2 | eval response_time=mvindex(Time,1)-mvindex(Time,0) | convert ctime(Time)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jul 2016 16:26:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274089#M82661</guid>
      <dc:creator>cj039165</dc:creator>
      <dc:date>2016-07-19T16:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference in two different logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274090#M82662</link>
      <description>&lt;P&gt;Try &lt;CODE&gt;transaction&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="/hdx2/was70-32/AppServer/profiles/AppSrv01/logs/PRD2_PY0/KAPE_Receive.log" OR source="/hdx2/was70-32/AppServer/profiles/AppSrv01/logs/PRD2_PY0/KAPE_Send.log" | transaction thread_id | rename duration AS response_time | table thread_id response_time 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jul 2016 16:44:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274090#M82662</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-07-19T16:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference in two different logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274091#M82663</link>
      <description>&lt;P&gt;Ran the search. I don't get an error, however I don't see any search results. Do I need to extract [thread-345432] into a extracted field? &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 16:53:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274091#M82663</guid>
      <dc:creator>cj039165</dc:creator>
      <dc:date>2016-07-19T16:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference in two different logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274092#M82664</link>
      <description>&lt;P&gt;Try the updated answer.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 17:00:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274092#M82664</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-07-19T17:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference in two different logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274093#M82665</link>
      <description>&lt;P&gt;You will have to extract the thread_id field. Try this (you may need to correct sent &amp;amp; received as well)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="/hdx2/was70-32/AppServer/profiles/AppSrv01/logs/PRD2_PY0/KAPE_Receive.log" OR source="/hdx2/was70-32/AppServer/profiles/AppSrv01/logs/PRD2_PY0/KAPE_Send.log" | rex "Thread-(?&amp;lt;thread_id&amp;gt;\d+)" | transaction thread_id startswith="sent" endswith="received" | rename duration AS response_time | table thread_id response_time 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jul 2016 17:02:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274093#M82665</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-07-19T17:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference in two different logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274094#M82666</link>
      <description>&lt;P&gt;I did your second search after extracting the thread-id. I'm see what I needed. Thanks very much for the help! &lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 17:27:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274094#M82666</guid>
      <dc:creator>cj039165</dc:creator>
      <dc:date>2016-07-19T17:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference in two different logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274095#M82667</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="/hdx2/was70-32/AppServer/profiles/AppSrv01/logs/PRD2_PY0/KAPE_Receive.log" OR source="/hdx2/was70-32/AppServer/profiles/AppSrv01/logs/PRD2_PY0/KAPE_Send.log" | stats min(_time) AS my_start,max(_time) AS my_end by  thread_id| eval reponse_time=my_end-my_start
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jul 2016 17:45:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274095#M82667</guid>
      <dc:creator>apilger_splunk</dc:creator>
      <dc:date>2016-07-19T17:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference in two different logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274096#M82668</link>
      <description>&lt;P&gt;Noticed a problem with the search results. It turns out it's possible to have the same thread-id in on multiple servers. For example [Thread-216189] can be in UNITED_Send.log / UNITED_Receive.log on HOST WASAPP07 or WASAPP08 or WASAPP09. How do I get it to not calculate across the hosts?&lt;/P&gt;

&lt;P&gt;Search String:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=hdx_payer source="/hdx2/was70-32/AppServer/profiles/AppSrv01/logs/PRD2_PY0/UNITED_Receive.log" OR source="/hdx2/was70-32/AppServer/profiles/AppSrv01/logs/PRD2_PY0/UNITED_Send.log" | eval Time=_time | stats values(Time) as Time by thread_id | where mvcount(Time)=2 | eval response_time=tonumber(mvindex(Time,1))-tonumber(mvindex(Time,0)) | convert ctime(Time)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:23:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274096#M82668</guid>
      <dc:creator>cj039165</dc:creator>
      <dc:date>2020-09-29T10:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference in two different logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274097#M82669</link>
      <description>&lt;P&gt;Just include the host field in the transaction command&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 19:36:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274097#M82669</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-07-26T19:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference in two different logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274098#M82670</link>
      <description>&lt;P&gt;Tried it yesterday. For some reason that did not work. It appears adding host=* shows the right data. Will review with the group looking for the info. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 20:39:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-in-two-different-logs/m-p/274098#M82670</guid>
      <dc:creator>cj039165</dc:creator>
      <dc:date>2016-07-26T20:39:48Z</dc:date>
    </item>
  </channel>
</rss>

