<?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 find difference between endTime and beginTime to find response time? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249089#M74368</link>
    <description>&lt;P&gt;You can use the round command to trim it to show only 3 digits after decimal.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your base search | eval response_time=strptime(endTime,"%Y/%m/%d %H:%M:%S.%3N") - strptime(beginTime,"%Y/%m/%d %H:%M:%S.%3N") | eval response_time=round(response_time,3)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 23 Jan 2017 17:38:43 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-01-23T17:38:43Z</dc:date>
    <item>
      <title>How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249078#M74357</link>
      <description>&lt;P&gt;In logs we have endTime and beginTime, the difference of these timings gives response time of that event. Format of beginTime and endtime are   &lt;CODE&gt;%Y-%m-%d %H:%M:%S.%3N&lt;/CODE&gt; (eg. 2017/01/20 14:24:48.288). &lt;/P&gt;

&lt;P&gt;Could some explain how to find difference of these timing variables of same event?&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jan 2017 07:52:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249078#M74357</guid>
      <dc:creator>huligesh</dc:creator>
      <dc:date>2017-01-22T07:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249079#M74358</link>
      <description>&lt;P&gt;Assuming the fields endTime and beginTime are extracted, Splunk will be treating them as strings. To do mathematical operations on them, you need to convert them to epoch format (may be temporarily) using strptime function in eval, like this:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Updated Time format for sample events provided in comments below&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | eval response_time=strptime(endTime,"%Y/%m/%d %H:%M:%S.%3N") - strptime(beginTime,"%Y/%m/%d %H:%M:%S.%3N") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See this for more information on strptime command.&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions#Date_and_Time_functions"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions#Date_and_Time_functions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jan 2017 20:30:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249079#M74358</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-22T20:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249080#M74359</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Thanks for you time. I tried and I got blank data in response_time. You have assumed endTime and beginTime are extracted, I want to make sure how our log looks. Below is the sample log:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;timestamp=2017/01/20 14:24:48.335;resource=;beginTime=2017/01/20 14:24:48.288;endTime=2017/01/20 14:24:48.335;generateRecord=True;os=Longhorn;gmtOffset=-0500;
taxonomyNodeGuid=;topicName=;transId=ddb4kbc4-2rc4-4265-9484-6be12b4ca0ef;sessionId=c99r725c-aa5c-4553-9ddb-5f74e3543e36;researchThreadId=60552351-f47f-49fc-a2f6-eba5hf521033;.....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;beginTime and endTime field type are "string" as seen in AllFields window. I see no data in response time column for below query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search| eval response_time=strptime(endTime,"%Y-%m-%d %H:%M:%S.%3N") - strptime(beginTime,"%Y-%m-%d %H:%M:%S.%3N") | table response_time, beginTime, endTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 15:01:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249080#M74359</guid>
      <dc:creator>huligesh</dc:creator>
      <dc:date>2017-01-23T15:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249081#M74360</link>
      <description>&lt;P&gt;Since the field  values contain space, I'm guessing the full values are not captured. Could you run this and see if you get full date in format "%Y-%m-%d %H:%M:%S.%3N" for both beginTime and endTime?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | head 10 | table beginTime endTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If they are not coming as full values, try something like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex "beginTime=(?&amp;lt;beginTime&amp;gt;[^;]+);endTime=(?&amp;lt;endTime&amp;gt;[^;]+)" | eval response_time=strptime(endTime,"%Y-%m-%d %H:%M:%S.%3N") - strptime(beginTime,"%Y-%m-%d %H:%M:%S.%3N") 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 16:42:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249081#M74360</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-23T16:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249082#M74361</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
base search | head 10 | table beginTime endTime result is displaying beginTime and endTime in table without any issues. However, I tried 2nd query you provided and not getting values in response_time column.&lt;/P&gt;

&lt;P&gt;Please let me know if you need info here. Appreciate you time!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 16:53:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249082#M74361</guid>
      <dc:creator>huligesh</dc:creator>
      <dc:date>2017-01-23T16:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249083#M74362</link>
      <description>&lt;P&gt;Found the issue. The time.format doesn't match the raw data. Try the updated query&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 16:57:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249083#M74362</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-23T16:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249084#M74363</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
could you provide the updated query? I don't see updated query in your previous commet&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:02:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249084#M74363</guid>
      <dc:creator>huligesh</dc:creator>
      <dc:date>2017-01-23T17:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249085#M74364</link>
      <description>&lt;P&gt;The original answer is updated.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:08:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249085#M74364</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-23T17:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249086#M74365</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I tried below query:&lt;BR /&gt;
base search | rex "beginTime=(?[^;]+);endTime=(?[^;]+)" | eval response_time=strptime(endTime,"%Y-%m-%d %H:%M:%S.%3N") - strptime(beginTime,"%Y-%m-%d %H:%M:%S.%3N") | table response_time, beginTime&lt;/P&gt;

&lt;P&gt;Result: response_time column is blank, beginTime has data&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:31:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249086#M74365</guid>
      <dc:creator>huligesh</dc:creator>
      <dc:date>2020-09-29T12:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249087#M74366</link>
      <description>&lt;P&gt;The timeformat has to be changed in the strptime command. Have you tried updated one?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | eval response_time=strptime(endTime,"%Y/%m/%d %H:%M:%S.%3N") - strptime(beginTime,"%Y/%m/%d %H:%M:%S.%3N")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:25:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249087#M74366</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-23T17:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249088#M74367</link>
      <description>&lt;P&gt;Thank you! Appreciate, I got response_time now.&lt;/P&gt;

&lt;P&gt;Response times are format x.xxxxxx. I want to display x.xxx, how this could be done?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:32:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249088#M74367</guid>
      <dc:creator>huligesh</dc:creator>
      <dc:date>2017-01-23T17:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249089#M74368</link>
      <description>&lt;P&gt;You can use the round command to trim it to show only 3 digits after decimal.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your base search | eval response_time=strptime(endTime,"%Y/%m/%d %H:%M:%S.%3N") - strptime(beginTime,"%Y/%m/%d %H:%M:%S.%3N") | eval response_time=round(response_time,3)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:38:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249089#M74368</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-23T17:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to find difference between endTime and beginTime to find response time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249090#M74369</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 18:42:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-difference-between-endTime-and-beginTime-to-find/m-p/249090#M74369</guid>
      <dc:creator>huligesh</dc:creator>
      <dc:date>2017-01-23T18:42:12Z</dc:date>
    </item>
  </channel>
</rss>

