<?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 duration of connection in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/calculate-duration-of-connection/m-p/82210#M20859</link>
    <description>&lt;P&gt;If you are getting your timestamps indexed correctly, then the "duration" field which is created for every "transaction" event will show you your duration in seconds.  In your example the duration should be "8", as the difference between the 10:21:50 and 10:21:58 in your timestamps.&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jul 2013 22:08:00 GMT</pubDate>
    <dc:creator>Jon_Webster</dc:creator>
    <dc:date>2013-07-03T22:08:00Z</dc:date>
    <item>
      <title>calculate duration of connection</title>
      <link>https://community.splunk.com/t5/Splunk-Search/calculate-duration-of-connection/m-p/82209#M20858</link>
      <description>&lt;P&gt;I have these two log messages&lt;/P&gt;

&lt;P&gt;Jul  2 10:21:50 10.197.1.254 id=firewall sn=0017C5C027C1 time="2013-07-02 17:21:50 UTC" fw=67.115.118.49 pri=6 c=262144 m=98 msg="Connection Opened" n=565679 src=192.168.168.65:1330:MGMT dst=192.168.168.169:443:MGMT proto=tcp/https sent=64&lt;/P&gt;

&lt;P&gt;ul  2 10:21:58 10.197.1.254 id=firewall sn=0017C5C027C1 time="2013-07-02 17:21:57 UTC" fw=67.115.118.49 pri=6 c=1024 m=537 msg="Connection Closed" n=606900 src=192.168.168.65:1330:MGMT dst=192.168.168.169:443:MGMT proto=tcp/https sent=670 rcvd=473 spkt=8 rpkt=6 cdur=7366&lt;/P&gt;

&lt;P&gt;As you can see the first one is for "Connection Opened" and the second "Connection Closed". Both the src and dst are the same so I believe this is a single stream. How do I calculate the total duration of this connection?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2013 17:25:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/calculate-duration-of-connection/m-p/82209#M20858</guid>
      <dc:creator>jalfrey</dc:creator>
      <dc:date>2013-07-02T17:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: calculate duration of connection</title>
      <link>https://community.splunk.com/t5/Splunk-Search/calculate-duration-of-connection/m-p/82210#M20859</link>
      <description>&lt;P&gt;If you are getting your timestamps indexed correctly, then the "duration" field which is created for every "transaction" event will show you your duration in seconds.  In your example the duration should be "8", as the difference between the 10:21:50 and 10:21:58 in your timestamps.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2013 22:08:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/calculate-duration-of-connection/m-p/82210#M20859</guid>
      <dc:creator>Jon_Webster</dc:creator>
      <dc:date>2013-07-03T22:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: calculate duration of connection</title>
      <link>https://community.splunk.com/t5/Splunk-Search/calculate-duration-of-connection/m-p/82211#M20860</link>
      <description>&lt;P&gt;There are many ways to tackle this problem. One is to use the &lt;CODE&gt;transaction&lt;/CODE&gt; command, which will automatically create a field called &lt;CODE&gt;duration&lt;/CODE&gt; for you. This example creates the transactions and formats a nice table&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere ("Connection Opened" OR "Connection Closed")
| transaction src dst startswith="Connection Opened" endswith="Connection Closed"
| table _time as StartTime duration src dst
| fieldformat duration=tostring(duration,"duration")
| fieldformat StartTime=strftime(StartTime,"%x %X")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jul 2013 22:15:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/calculate-duration-of-connection/m-p/82211#M20860</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-07-03T22:15:34Z</dc:date>
    </item>
  </channel>
</rss>

