<?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 can I subtract two timestamp fields in a transaction to get duration? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434055#M75835</link>
    <description>&lt;P&gt;This is what it returns as one event with the transaction command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; {
    "engine": {
      "currentTimestamp": "2018-12-11T13:54:16.869+01:00",
      "localization": "Central European Time",
      "processId": "10790@DESKTOP-68CLR",
      "applicationName": "cr_quotes",
      "messageId": "de1d3e0-fd4311e8-811c-005056a4ee"
    },
    "tracepoint": "Entry"
  }
{
    "engine": {
      "currentTimestamp": "2018-12-11T13:54:16.967+01:00",
      "localization": "Central European Time",
      "processId": "10790@DESKTOP-68CLR",
      "applicationName": "cr_quotes",
      "messageId": "de46d3e0-fd43-11e8-8f1c-0050563ee"
    },
    "tracepoint": "Exit"
  }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this answers the question!&lt;/P&gt;</description>
    <pubDate>Tue, 11 Dec 2018 13:06:47 GMT</pubDate>
    <dc:creator>ykoolhout</dc:creator>
    <dc:date>2018-12-11T13:06:47Z</dc:date>
    <item>
      <title>How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434047#M75827</link>
      <description>&lt;P&gt;Helllo, I've been trying to subtract two timestamp fields from each other within a transaction. A timestamp as such:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2018-12-11T09:54:16.869+01:00
2018-12-11T09:54:16.874+01:00
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The current search I'm using is as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=testindex sourcetype="_json" 
| transaction engine.correlationId startswith="tracepoint=Entry" endswith="tracepoint=Exit" mvlist=engine.currentTimestamp
| eval firstValue1=mvindex(engine.currentTimestamp,0) 
| eval secondValue1=mvindex(engine.currentTimestamp,1) 

| eval end_time_epoch = strptime(firstValue1, "%Y-%m-%dT%H:%M:%S.%f")
| eval begin_time_epoch = strptime(secondValue1, "%Y-%m-%dT%H:%M:%S.%f")
| eval duration = end_time_epoch - begin_time_epoch

| table engine.currentTimestamp firstValue1 secondValue1 duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was expecting to get "duration" as the two timestamps subtracted from the from each other, which would give the difference in milliseconds. For some reason, only engine.currentTimestamp is returning the multiple timestamp-values of the transaction and the other fields are returning empty in the table.&lt;/P&gt;

&lt;P&gt;Perhaps it is the mvlist, which isn't working, but it could also be the calculation since it is trying to subtract within a transaction that has 2 or 3 timestamps from 2 or 3 events.&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 09:19:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434047#M75827</guid>
      <dc:creator>ykoolhout</dc:creator>
      <dc:date>2018-12-11T09:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434048#M75828</link>
      <description>&lt;P&gt;Hi! Can you post the value of engine.currentTimestamp of one sample event?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 12:23:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434048#M75828</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2018-12-11T12:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434049#M75829</link>
      <description>&lt;P&gt;Hi whrg,&lt;/P&gt;

&lt;P&gt;A single value would be as follows:&lt;BR /&gt;
    "currentTimestamp": "2018-12-11T13:24:16.869+01:00"&lt;BR /&gt;
Though in a transaction it would have multiple timestamps.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 12:30:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434049#M75829</guid>
      <dc:creator>ykoolhout</dc:creator>
      <dc:date>2018-12-11T12:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434050#M75830</link>
      <description>&lt;P&gt;Having a look at &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.0.0/SearchReference/Commontimeformatvariables"&gt;Date and time format variables&lt;/A&gt;, &lt;EM&gt;%f&lt;/EM&gt; is not listed. So you might need to change the time format for the &lt;EM&gt;strptime&lt;/EM&gt; function.&lt;/P&gt;

&lt;P&gt;Perhaps this will work better:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=1 | eval timestamp="2018-12-11T13:24:16.869+01:00"
| eval epoch_time = strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%3N%:z")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Dec 2018 12:41:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434050#M75830</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2018-12-11T12:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434051#M75831</link>
      <description>&lt;P&gt;Does engine.currentTimestamp exist as a multivalue field after the transaction command?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 12:49:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434051#M75831</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2018-12-11T12:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434052#M75832</link>
      <description>&lt;P&gt;This seems to have fixed the time layout, as this command works. Something else seems to be going on though.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 12:51:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434052#M75832</guid>
      <dc:creator>ykoolhout</dc:creator>
      <dc:date>2018-12-11T12:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434053#M75833</link>
      <description>&lt;P&gt;Not too sure how to check this&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 12:53:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434053#M75833</guid>
      <dc:creator>ykoolhout</dc:creator>
      <dc:date>2018-12-11T12:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434054#M75834</link>
      <description>&lt;P&gt;Search for index=... | transaction ...&lt;BR /&gt;
(That is, remove the lines after transaction.)&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 12:55:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434054#M75834</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2018-12-11T12:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434055#M75835</link>
      <description>&lt;P&gt;This is what it returns as one event with the transaction command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; {
    "engine": {
      "currentTimestamp": "2018-12-11T13:54:16.869+01:00",
      "localization": "Central European Time",
      "processId": "10790@DESKTOP-68CLR",
      "applicationName": "cr_quotes",
      "messageId": "de1d3e0-fd4311e8-811c-005056a4ee"
    },
    "tracepoint": "Entry"
  }
{
    "engine": {
      "currentTimestamp": "2018-12-11T13:54:16.967+01:00",
      "localization": "Central European Time",
      "processId": "10790@DESKTOP-68CLR",
      "applicationName": "cr_quotes",
      "messageId": "de46d3e0-fd43-11e8-8f1c-0050563ee"
    },
    "tracepoint": "Exit"
  }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this answers the question!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 13:06:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434055#M75835</guid>
      <dc:creator>ykoolhout</dc:creator>
      <dc:date>2018-12-11T13:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434056#M75836</link>
      <description>&lt;P&gt;Hi again! Apparently, the issue lies with this line:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval firstValue1=mvindex(engine.currentTimestamp,0) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I believe the dot is causing the issue. Can you try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval firstValue1=mvindex("engine.currentTimestamp",0) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Dec 2018 14:42:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434056#M75836</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2018-12-11T14:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434057#M75837</link>
      <description>&lt;P&gt;You were right, the dot caused an issue. I believe there is something I'm missing though. I was expecting the firstValue1 and secondValue1 to set the value of the timestamp, not the name of the field. Heres a sample output below: &lt;BR /&gt;
&lt;IMG src="https://i.postimg.cc/dQjbsfvG/Knipsel.png" alt="alt text" /&gt;&lt;BR /&gt;
Perhaps something with mvlist or mvindex?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 19:19:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434057#M75837</guid>
      <dc:creator>ykoolhout</dc:creator>
      <dc:date>2018-12-11T19:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434058#M75838</link>
      <description>&lt;P&gt;Instead of double quotes, try single quotes as I just read here: &lt;A href="https://answers.splunk.com/answers/211991/dealing-with-field-names-with-a-period-in-it.html"&gt;Dealing with field names with a period in it&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval firstValue1=mvindex('engine.currentTimestamp',0) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Dec 2018 20:02:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434058#M75838</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2018-12-11T20:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434059#M75839</link>
      <description>&lt;P&gt;Fixed it, turns out indeed the dot between "engine.currentTimestamp" was causing the problem.&lt;BR /&gt;
a simple "rename *** AS ****" fixed the problem. Thanks for the input whrg!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 20:15:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434059#M75839</guid>
      <dc:creator>ykoolhout</dc:creator>
      <dc:date>2018-12-11T20:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I subtract two timestamp fields in a transaction to get duration?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434060#M75840</link>
      <description>&lt;P&gt;Guess it's so simple you look over it. But the single quotes work aswell! Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 08:44:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-subtract-two-timestamp-fields-in-a-transaction-to-get/m-p/434060#M75840</guid>
      <dc:creator>ykoolhout</dc:creator>
      <dc:date>2018-12-12T08:44:30Z</dc:date>
    </item>
  </channel>
</rss>

