<?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: subtracting two timestamps per logEvevtType in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/627984#M218173</link>
    <description>&lt;P&gt;Thank you, that is a huge help. Question, if I had multiple calls, how do I get the SPL to subtract timestamp by RequestID? I don't need the RequestID in the stats, but want the SPL to capture the difference in timestamps &lt;STRONG&gt;per call&lt;/STRONG&gt;. And then take the 95th percentile of that call per day?&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2023 13:30:12 GMT</pubDate>
    <dc:creator>user33</dc:creator>
    <dc:date>2023-01-23T13:30:12Z</dc:date>
    <item>
      <title>How to subtract two timestamps per logEvevtType?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/627928#M218152</link>
      <description>&lt;P&gt;Hello, apologies if this was stated previously. I have multiple calls - each RequestID with a RequestReceive and ResponseTransmit. I am trying to find the difference between the two timestamps below. The difference of &lt;EM&gt;ResponseTransmit&lt;/EM&gt; timestamp and&amp;nbsp;&lt;EM&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;RequestReceive &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;timestamp. Then put that into a stats command ordered by clientPathURI and then the difference between the timestamps.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Any assistance is much appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;{&amp;nbsp;&lt;A class="" href="https://splunk4.wellsfargo.net/en-US/app/wf-s-1baas_wfgateway/search?q=search%20index%3Dwf_pvsi*%20sourcetype%3Dwf%3Aeser%3Ajson%20clientPathURI%3Dsignup%20%7C%20spath%20input%3Dpayload%20%7C%20extract%20kvdelim%3D%22%3A%22%20pairdelim%3D%22~%22%0A%7C%20convert%20timeformat%3D%22%25Y-%25m-%25d%22%20ctime(_time)%20AS%20date%0A%7C%20eval%20responsetime%3Dstrptime(ResponseTransmit.timestamp%2C%22%25Y-%25m-%25dT%25H%3A%25M%3A%25S.%25Q%22)-strptime(RequestReceive.timestamp%2C%22%25Y-%25m-%25dT%25H%3A%25M%3A%25S.%25Q%22)%0A%60%60%60%7C%20eval%20responsetime(ms)%3Dabs((end-start)*1000)%60%60%60%0A%7C%20table%20responsetime&amp;amp;display.page.search.mode=verbose&amp;amp;dispatch.sample_ratio=1&amp;amp;earliest=-7d%40h&amp;amp;latest=now&amp;amp;display.page.search.tab=events&amp;amp;display.general.type=statistics&amp;amp;sid=1674441657.221007_AC6A5BD0-27D4-48EF-AB09-A2C4E8417B3C#" target="_blank" rel="noopener"&gt;[-]&lt;/A&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;RequestID&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;b74fab20-9a7b-11ed-bd70-c503548afa99&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;clientPathURI&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;signup&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;level&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;Info&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;logEventType&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;ResponseTransmit&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;timestamp&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;2023-01-22T12:43:57.547-05:00&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;{&amp;nbsp;&lt;A class="" href="https://splunk4.wellsfargo.net/en-US/app/wf-s-1baas_wfgateway/search?q=search%20index%3Dwf_pvsi*%20sourcetype%3Dwf%3Aeser%3Ajson%20clientPathURI%3Dsignup%20%7C%20spath%20input%3Dpayload%20%7C%20extract%20kvdelim%3D%22%3A%22%20pairdelim%3D%22~%22%0A%7C%20convert%20timeformat%3D%22%25Y-%25m-%25d%22%20ctime(_time)%20AS%20date%0A%7C%20eval%20responsetime%3Dstrptime(ResponseTransmit.timestamp%2C%22%25Y-%25m-%25dT%25H%3A%25M%3A%25S.%25Q%22)-strptime(RequestReceive.timestamp%2C%22%25Y-%25m-%25dT%25H%3A%25M%3A%25S.%25Q%22)%0A%60%60%60%7C%20eval%20responsetime(ms)%3Dabs((end-start)*1000)%60%60%60%0A%7C%20table%20responsetime&amp;amp;display.page.search.mode=verbose&amp;amp;dispatch.sample_ratio=1&amp;amp;earliest=-7d%40h&amp;amp;latest=now&amp;amp;display.page.search.tab=events&amp;amp;display.general.type=statistics&amp;amp;sid=1674441657.221007_AC6A5BD0-27D4-48EF-AB09-A2C4E8417B3C#" target="_blank" rel="noopener"&gt;[-]&lt;/A&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;RequestID&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;b74fab20-9a7b-11ed-bd70-c503548afa99&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;clientPathURI&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;signup&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;level&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;Info&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;logEventType&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;RequestReceive&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;timestamp&lt;/SPAN&gt;:&amp;nbsp;&lt;SPAN class=""&gt;2023-01-22T12:43:57.496-05:00&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;}&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 00:21:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/627928#M218152</guid>
      <dc:creator>user33</dc:creator>
      <dc:date>2023-01-24T00:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: subtracting two timestamps per logEvevtType</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/627929#M218153</link>
      <description>&lt;P&gt;Assuming the "}" in the second block is not really there and the fields from the event are extracted as per their JSON names, then this will aggregate min/max timestamps and calculated duration&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval ts=strptime(timestamp, "%FT%T.%Q-%:z")
| stats min(ts) as mints max(ts) as maxts by clientPathURI RequestID
| eval duration=maxts-mints&lt;/LI-CODE&gt;&lt;P&gt;then if you want to aggregate based on the clientPathURI only, do another stats, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats avg(duration) as avgDuration by clientPathURI&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 23 Jan 2023 03:53:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/627929#M218153</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-01-23T03:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: subtracting two timestamps per logEvevtType</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/627984#M218173</link>
      <description>&lt;P&gt;Thank you, that is a huge help. Question, if I had multiple calls, how do I get the SPL to subtract timestamp by RequestID? I don't need the RequestID in the stats, but want the SPL to capture the difference in timestamps &lt;STRONG&gt;per call&lt;/STRONG&gt;. And then take the 95th percentile of that call per day?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 13:30:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/627984#M218173</guid>
      <dc:creator>user33</dc:creator>
      <dc:date>2023-01-23T13:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: subtracting two timestamps per logEvevtType</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/627985#M218174</link>
      <description>&lt;P&gt;as a follow up, each "transaction" or "call" has one RequestID. Each RequestID with two timnestamps, one Request and one Response. Something like the below? Any assistance is appreciated.&lt;/P&gt;&lt;TABLE border="1" width="63.9995801353192%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="20%"&gt;Date&lt;/TD&gt;&lt;TD width="20%"&gt;ClientPathURI&lt;/TD&gt;&lt;TD width="20%"&gt;Number of calls&lt;/TD&gt;&lt;TD width="20%"&gt;95thpercentile of Duration&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="20%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="20%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="20%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="20%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="20%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="20%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 23 Jan 2023 13:33:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/627985#M218174</guid>
      <dc:creator>user33</dc:creator>
      <dc:date>2023-01-23T13:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: subtracting two timestamps per logEvevtType</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/628050#M218190</link>
      <description>&lt;P&gt;You can do all that in the last stats command, so do this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| bin _time span=1d
| eval ts=strptime(timestamp, "%FT%T.%Q-%:z")
| stats min(ts) as mints max(ts) as maxts by _time clientPathURI RequestID
| eval duration=maxts-mints
| stats count as Calls perc95(duration) as p95Duration by _time clientPathURI&lt;/LI-CODE&gt;&lt;P&gt;so this is doing&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;line 1 - creates a time bucket to calculate statistics by day&lt;/LI&gt;&lt;LI&gt;line 2 - converts timestamp to epoch&lt;/LI&gt;&lt;LI&gt;line 3 - calculates min/max timestamp by URI and Request&lt;/LI&gt;&lt;LI&gt;line 4 - calculates duration&lt;/LI&gt;&lt;LI&gt;line 5 - counts the calls, 95th percentile of duration by day and URI&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Some caveats here&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If you don't have&amp;nbsp;&lt;STRONG&gt;both&lt;/STRONG&gt; request/response for each call, then duration will be 0 for that, as min/max are the same&lt;/LI&gt;&lt;LI&gt;If a call goes over midnight, you will get 1 call with duration 0 on each day for the same RequestID&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;If relevant, you may want to consider error/failure status in these if they are significant and if they affect the duration in a meaningful way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 23:16:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/628050#M218190</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-01-23T23:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: subtracting two timestamps per logEvevtType</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/628180#M218216</link>
      <description>&lt;P&gt;Awesome! Excellent insights!! This solution worked out great. I will take a look at failures as well. Thank you very much for this!!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 17:47:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-two-timestamps-per-logEvevtType/m-p/628180#M218216</guid>
      <dc:creator>user33</dc:creator>
      <dc:date>2023-01-24T17:47:39Z</dc:date>
    </item>
  </channel>
</rss>

