<?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 Can we use Start/End times from a query to get duration to use it in another search query to get an average of a field in that duration ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-we-use-Start-End-times-from-a-query-to-get-duration-to-use/m-p/290166#M87728</link>
    <description>&lt;P&gt;I am able to get the Start/End times of a load test execution from a search query (by getting End time from Timestamp (field) of the log data, and subtracting the duration (field) to get Start time.&lt;BR /&gt;
Now I want to use this Start time, End time and duration between them in another search query with a different sourcetype such that it would fetch all the data inputs falling within that time duration (between Start/End times) from another app logs - to calculate the average/count of a field.&lt;BR /&gt;
So, please help me in achieving the desired data with the required search queries (using subsearch/joins etc.)&lt;/P&gt;</description>
    <pubDate>Sun, 07 Jan 2018 15:05:24 GMT</pubDate>
    <dc:creator>MSaraswat</dc:creator>
    <dc:date>2018-01-07T15:05:24Z</dc:date>
    <item>
      <title>Can we use Start/End times from a query to get duration to use it in another search query to get an average of a field in that duration ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-use-Start-End-times-from-a-query-to-get-duration-to-use/m-p/290166#M87728</link>
      <description>&lt;P&gt;I am able to get the Start/End times of a load test execution from a search query (by getting End time from Timestamp (field) of the log data, and subtracting the duration (field) to get Start time.&lt;BR /&gt;
Now I want to use this Start time, End time and duration between them in another search query with a different sourcetype such that it would fetch all the data inputs falling within that time duration (between Start/End times) from another app logs - to calculate the average/count of a field.&lt;BR /&gt;
So, please help me in achieving the desired data with the required search queries (using subsearch/joins etc.)&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jan 2018 15:05:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-use-Start-End-times-from-a-query-to-get-duration-to-use/m-p/290166#M87728</guid>
      <dc:creator>MSaraswat</dc:creator>
      <dc:date>2018-01-07T15:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Can we use Start/End times from a query to get duration to use it in another search query to get an average of a field in that duration ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-use-Start-End-times-from-a-query-to-get-duration-to-use/m-p/290167#M87729</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;[search &amp;lt;your search that creates start/end fields&amp;gt; | rename start AS earliest, end AS latest | table earliest latest] &amp;lt;your new search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As a run-anywhere example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[| makeresults | eval start=relative_time(now(), "-10min"), end=relative_time(now(), "-5min") | rename start AS earliest, end AS latest | table earliest latest] index=_internal
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note the run-anywhere example doesn't have &lt;CODE&gt;search&lt;/CODE&gt; in the subsearch (between the &lt;CODE&gt;[]&lt;/CODE&gt;).  This is because &lt;CODE&gt;makeresults&lt;/CODE&gt; is a generating command.  I'm assuming your initial search that calculates start/end will use an indexed search, and the &lt;CODE&gt;search&lt;/CODE&gt; command that would be assumed in your main search string must be explicitly included inside a subsearch.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jan 2018 18:20:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-use-Start-End-times-from-a-query-to-get-duration-to-use/m-p/290167#M87729</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-07T18:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can we use Start/End times from a query to get duration to use it in another search query to get an average of a field in that duration ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-we-use-Start-End-times-from-a-query-to-get-duration-to-use/m-p/290168#M87730</link>
      <description>&lt;P&gt;Hi MSaraswat,&lt;BR /&gt;
try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index1 sourcetype=my_sourcetype1 [ search index=my_index2 sourcetype=my_sourcetype2 | rename Timestamp AS latest | eval earliest=strptime(latest,"time_format")-duration | fields earliest latest ]
| ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(I don't know the Timestamp field format so you have to customize it).&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 07:39:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-we-use-Start-End-times-from-a-query-to-get-duration-to-use/m-p/290168#M87730</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2018-01-08T07:39:36Z</dc:date>
    </item>
  </channel>
</rss>

