<?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 start and end time from two different searches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403024#M169367</link>
    <description>&lt;P&gt;There were spaces around the RequestID, I used the trim command to remove the spaces and it worked perfectly. Thanks a lot for your help!&lt;/P&gt;

&lt;P&gt;One last thing is there an easy way to group the duration in a bar chart? &lt;BR /&gt;
For example I will like to group the requests by 5min spans i.e show the total number of requests that take 0-5 mins, 5-10 mins  10-15 mins etc. &lt;/P&gt;</description>
    <pubDate>Fri, 18 May 2018 18:35:53 GMT</pubDate>
    <dc:creator>kaphie2002</dc:creator>
    <dc:date>2018-05-18T18:35:53Z</dc:date>
    <item>
      <title>How to calculate start and end time from two different searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403018#M169361</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  I am trying to calculate the total time it takes for a request to be processed. I have two searches, the first search display the start time and the second search displays the end time. Now I need to create a table or chart that shows the duration for each request.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Start time search - host=&lt;EM&gt;request&lt;/EM&gt; c.m.p.t.ThumbnailProcessor  | rex field=_raw ".&lt;EM&gt;jpg.(?.&lt;/EM&gt;).&lt;EM&gt;\"code&lt;/EM&gt;" | table RequestID _time&lt;/P&gt;

&lt;P&gt;End time search - host=&lt;EM&gt;images&lt;/EM&gt; Successfully rendered | rex field=_raw ".&lt;EM&gt;images//(?.&lt;/EM&gt;).jpg" | table RequestID _time&lt;/P&gt;

&lt;P&gt;How do I combine these two searches? &lt;/P&gt;

&lt;P&gt;I tried using append to combine both search results but I was only able to get the results i.e time and request ID from one search and not both. &lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Kafayat&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 16:55:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403018#M169361</guid>
      <dc:creator>kaphie2002</dc:creator>
      <dc:date>2018-05-17T16:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate start and end time from two different searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403019#M169362</link>
      <description>&lt;P&gt;I believe there are other, less expensive, ways to do this but I do it using transaction.&lt;/P&gt;

&lt;P&gt;You can do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(host=request OR host=images) ("c.m.p.t.ThumbnailProcessor" OR "Successfully rendered")  &amp;lt;- or however to combine your data
| eval Start_Time = case(host="request",_time)
| eval End_time = case(host="images",_time)
| transaction RequestID  (fill in maxspan, etc that fits your query)
| eval Elapsed_Time = (End_time - Start_Time)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 May 2018 17:25:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403019#M169362</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2018-05-17T17:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate start and end time from two different searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403020#M169363</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(host=*request* c.m.p.t.ThumbnailProcessor)  OR ( host=*images* Successfully rendered) 
| rex field=_raw ".*jpg.(?&amp;lt;RequestID1&amp;gt;.*).*\"code*"  | rex field=_raw ".*images//(?&amp;lt;RequestID2&amp;gt;.*).jpg" 
| eval RequestID=coalesce(RequestID1,RequestID2) | eval host=if(match(host,"request"),"Start","End")
| chart values(_time) over RequestID by host | eval Duration=End-Start
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 May 2018 18:11:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403020#M169363</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-17T18:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate start and end time from two different searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403021#M169364</link>
      <description>&lt;P&gt;Hello Somesoni2,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   Thanks for your response, I think I'm pretty close. I used the query above but I am not getting the Duration in the output. The table shows 2 entries for each requestID one for Start and another for End but I can't compute the difference. I tried using the table command to show to values for Duration but it was blank. I am quite new to splunk so I don't know where to go from here. Thanks 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;RequestID   Start             End &lt;BR /&gt;
123456        1526654924&lt;BR /&gt;&lt;BR /&gt;
123456                                 1526654930&lt;BR /&gt;
78965          1526654945&lt;BR /&gt;&lt;BR /&gt;
78965                                   1526654970&lt;BR /&gt;
654321         1526654985&lt;BR /&gt;&lt;BR /&gt;
654321                                   152665500&lt;/P&gt;

&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2018 15:07:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403021#M169364</guid>
      <dc:creator>kaphie2002</dc:creator>
      <dc:date>2018-05-18T15:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate start and end time from two different searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403022#M169365</link>
      <description>&lt;P&gt;Oh no the formatting is bad. the first requestID shows the start time while the second shows the end time. &lt;/P&gt;

&lt;P&gt;Thanks &lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2018 15:08:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403022#M169365</guid>
      <dc:creator>kaphie2002</dc:creator>
      <dc:date>2018-05-18T15:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate start and end time from two different searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403023#M169366</link>
      <description>&lt;P&gt;Strange. The host values should be mutually excluding for events from host request and images and there should've been just one row per RequestID. See if this variation works.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(host=*request* c.m.p.t.ThumbnailProcessor)  OR ( host=*images* Successfully rendered) 
 | rex field=_raw ".*jpg.(?&amp;lt;RequestID1&amp;gt;.*).*\"code*"  | rex field=_raw ".*images//(?&amp;lt;RequestID2&amp;gt;.*).jpg" 
 | eval RequestID=coalesce(RequestID1,RequestID2) 
 | eval Start=if(match(host,"request"),_time, null())
 | eval End=if(match(host,"images"),_time, null())
 | stats values(Start) as Start values(End) as End by RequestID | eval Duration=End-Start
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 May 2018 15:41:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403023#M169366</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-18T15:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate start and end time from two different searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403024#M169367</link>
      <description>&lt;P&gt;There were spaces around the RequestID, I used the trim command to remove the spaces and it worked perfectly. Thanks a lot for your help!&lt;/P&gt;

&lt;P&gt;One last thing is there an easy way to group the duration in a bar chart? &lt;BR /&gt;
For example I will like to group the requests by 5min spans i.e show the total number of requests that take 0-5 mins, 5-10 mins  10-15 mins etc. &lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2018 18:35:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403024#M169367</guid>
      <dc:creator>kaphie2002</dc:creator>
      <dc:date>2018-05-18T18:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate start and end time from two different searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403025#M169368</link>
      <description>&lt;P&gt;Sure. Just add this to your currently working search. Duration is right now showing in secs, so we'll convert it to minutes, then bin it in 5 min buckets and then a stats command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search | eval Duration=round(Duration/60) | bin span=5 Duration
| stats count by Duration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 May 2018 18:43:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-start-and-end-time-from-two-different-searches/m-p/403025#M169368</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-18T18:43:25Z</dc:date>
    </item>
  </channel>
</rss>

