<?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 the difference between timestamps? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-the-difference-between-timestamps/m-p/125753#M25925</link>
    <description>&lt;P&gt;&lt;CODE&gt;Transaction&lt;/CODE&gt; automatically creates a field called &lt;CODE&gt;duration&lt;/CODE&gt; that is the difference between the earliest and latest events in the transaction.  If your &lt;CODE&gt;Timestamp&lt;/CODE&gt; field is the same as the &lt;CODE&gt;_time&lt;/CODE&gt; field in each event, the work is already done for you.  &lt;/P&gt;

&lt;P&gt;Just a side note, I'd recommend beefing up your transaction definition so that you can ensure the events that are paired together actually go together.  By default, transaction combines events based on time, so if you have two CalculateTaxRequests start one after another, they could be combined into a transaction and your statistics would be off.  Perhaps a transaction definition like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=all  GUID="*" AND *calculatetax*   Timestamp="*" | transaction GUID startswith=CalculateTaxRequests endswith=CalculateTaxResponse  maxevents=2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 03 Feb 2015 20:11:04 GMT</pubDate>
    <dc:creator>wpreston</dc:creator>
    <dc:date>2015-02-03T20:11:04Z</dc:date>
    <item>
      <title>How to calculate the difference between timestamps?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-the-difference-between-timestamps/m-p/125752#M25924</link>
      <description>&lt;P&gt;I have a lot of SOAP request/response pairs indexed in Splunk. One of those are CalculateTaxRequest and CalculateTaxResponse. So when the call is made it will show &lt;CODE&gt;23:59:04,108&lt;/CODE&gt; and &lt;CODE&gt;23:59:04,437&lt;/CODE&gt; respectfully (hour/minute/second/millisecond). I have created a new field called TimeStamp which extracts the time for each call. I then wrote a search for &lt;CODE&gt;...|transaction maxevents=2&lt;/CODE&gt; and assigned another field (GUID) which matches the unique identifiers for the request/response in one field. &lt;/P&gt;

&lt;P&gt;My current query is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=all  GUID="*" AND *calculatetax*   Timestamp="*" | transaction maxevents=2 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This search returns the request and response for calculatetax in the same field along with returning the timestamp for both fields. So now I would like to take those 2 timestamps and subtract them and have another field output the difference between the two in the same field. I'm doing this so I don't have to manually calculate the difference and see which services too longer then the others. Thanks in advance! &lt;/P&gt;</description>
      <pubDate>Tue, 03 Feb 2015 18:53:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-the-difference-between-timestamps/m-p/125752#M25924</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-02-03T18:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference between timestamps?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-the-difference-between-timestamps/m-p/125753#M25925</link>
      <description>&lt;P&gt;&lt;CODE&gt;Transaction&lt;/CODE&gt; automatically creates a field called &lt;CODE&gt;duration&lt;/CODE&gt; that is the difference between the earliest and latest events in the transaction.  If your &lt;CODE&gt;Timestamp&lt;/CODE&gt; field is the same as the &lt;CODE&gt;_time&lt;/CODE&gt; field in each event, the work is already done for you.  &lt;/P&gt;

&lt;P&gt;Just a side note, I'd recommend beefing up your transaction definition so that you can ensure the events that are paired together actually go together.  By default, transaction combines events based on time, so if you have two CalculateTaxRequests start one after another, they could be combined into a transaction and your statistics would be off.  Perhaps a transaction definition like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=all  GUID="*" AND *calculatetax*   Timestamp="*" | transaction GUID startswith=CalculateTaxRequests endswith=CalculateTaxResponse  maxevents=2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Feb 2015 20:11:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-the-difference-between-timestamps/m-p/125753#M25925</guid>
      <dc:creator>wpreston</dc:creator>
      <dc:date>2015-02-03T20:11:04Z</dc:date>
    </item>
  </channel>
</rss>

