<?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: Using result fields for earliest/latest time in secondary search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-result-fields-for-earliest-latest-time-in-secondary-search/m-p/469867#M146100</link>
    <description>&lt;P&gt;There is no direct relationship between them, the three values "RunTime, StartTime and EndTime" are all unique fields that come from the opening search. Fortunately there will only ever be ~6 sets of values returned from the opening search. &lt;/P&gt;

&lt;P&gt;I will try this out and share my results. Thank you somesoni2!&lt;/P&gt;</description>
    <pubDate>Mon, 10 Feb 2020 21:03:17 GMT</pubDate>
    <dc:creator>lukepatrick</dc:creator>
    <dc:date>2020-02-10T21:03:17Z</dc:date>
    <item>
      <title>Using result fields for earliest/latest time in secondary search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-result-fields-for-earliest-latest-time-in-secondary-search/m-p/469865#M146098</link>
      <description>&lt;P&gt;I have an existing search that finds fields named "RunDate" "StartTime" "EndTime" stored as part of test run summaries. The search then proceeds to convert those time values into usable Unix, via strptime:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="IDX1" sourcetype="SRC" ProjectName="PRJ" | eval stime = strptime(StartTime,"%m/%d/%Y %I:%M:%S %p") | eval etime = strptime(EndTime,"%m/%d/%Y %I:%M:%S %p") | table RunDate stime etime | sort RunDate desc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now is the tricky part...&lt;BR /&gt;
I would like a 4th column that uses the time frame in each row to perform a calculation on values coming from a different index/source.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="IDX2" "HOST" "data.metricId" IN (1234) | stats avg("data.metricValues{}.value") as average | eval total=average/100 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Somehow, this needs to be time constrained by "earliest=stime" &amp;amp; "latest=etime" for each RunDate (the results should be a series)&lt;/P&gt;

&lt;P&gt;Is this possible? To run a secondary search/eval, using calculated values from the primary search as the earliest and latest time constraints?&lt;/P&gt;

&lt;P&gt;I attempted to do this with a maps search, but it seems that for a maps search to work properly, there must be an overlapping field. In this case, the only thing that overlaps between the two searches are the time parameters.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 19:16:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-result-fields-for-earliest-latest-time-in-secondary-search/m-p/469865#M146098</guid>
      <dc:creator>lukepatrick</dc:creator>
      <dc:date>2020-02-10T19:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Using result fields for earliest/latest time in secondary search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-result-fields-for-earliest-latest-time-in-secondary-search/m-p/469866#M146099</link>
      <description>&lt;P&gt;You'll use map like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="IDX1" sourcetype="SRC" ProjectName="PRJ" 
| eval stime = strptime(StartTime,"%m/%d/%Y %I:%M:%S %p") | eval etime = strptime(EndTime,"%m/%d/%Y %I:%M:%S %p") 
| table RunDate stime etime
| map maxsearches=1000 search="search index=\"IDX2\"" "HOST" "data.metricId" IN (1234) earliest=$stime$ latest=$etime$ | stats avg(\"data.metricValues{}.value\") as average | eval total=average/100 | eval RunDate=\"$RunDate$\", stime=$stime$, etime=$etime$ | table RunDate stime etime total"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will be slow (sometimes really slow). If there is a relationship between RunDate and stime (or etime), then this can be optimized. Do RunDate and stime/etime have any relationship?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 20:02:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-result-fields-for-earliest-latest-time-in-secondary-search/m-p/469866#M146099</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-02-10T20:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using result fields for earliest/latest time in secondary search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-result-fields-for-earliest-latest-time-in-secondary-search/m-p/469867#M146100</link>
      <description>&lt;P&gt;There is no direct relationship between them, the three values "RunTime, StartTime and EndTime" are all unique fields that come from the opening search. Fortunately there will only ever be ~6 sets of values returned from the opening search. &lt;/P&gt;

&lt;P&gt;I will try this out and share my results. Thank you somesoni2!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 21:03:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-result-fields-for-earliest-latest-time-in-secondary-search/m-p/469867#M146100</guid>
      <dc:creator>lukepatrick</dc:creator>
      <dc:date>2020-02-10T21:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using result fields for earliest/latest time in secondary search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-result-fields-for-earliest-latest-time-in-secondary-search/m-p/469868#M146101</link>
      <description>&lt;P&gt;Well, the search runs, but it returns results from the full time range, and is not being constrained by each of the 'earliest' and 'latest' values.&lt;BR /&gt;
I'm expecting 5 - 7 results, but am getting 50,000. I will return to this tomorrow.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 21:30:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-result-fields-for-earliest-latest-time-in-secondary-search/m-p/469868#M146101</guid>
      <dc:creator>lukepatrick</dc:creator>
      <dc:date>2020-02-10T21:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using result fields for earliest/latest time in secondary search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-result-fields-for-earliest-latest-time-in-secondary-search/m-p/469869#M146102</link>
      <description>&lt;P&gt;index="IDX1" AND sourcetype="SRC" AND ProjectName="PRJ" | eval stime = strptime(StartTime,"%m/%d/%Y %I:%M:%S %p") | eval etime = strptime(EndTime,"%m/%d/%Y %I:%M:%S %p") | dedup RunDate | map maxsearches=150 search="search index=\"IDX2\" \"HOST\" \"NODE\" "data.metricId" IN (1234) earliest=$stime$ latest=$etime$ | stats avg(data.metricValues{}.value) AS average | eval total=average/100, RunDate=$RunDate$, stime=$stime$, etime=$etime$" | table RunDate total | sort RunDate asc&lt;/P&gt;

&lt;P&gt;This works wonderfully directly from Search. It gets stuck on "Search is waiting for input..." as a panel. Not 100% there, but this was a huge help. Thank you somesoni2&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 14:23:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-result-fields-for-earliest-latest-time-in-secondary-search/m-p/469869#M146102</guid>
      <dc:creator>lukepatrick</dc:creator>
      <dc:date>2020-02-11T14:23:45Z</dc:date>
    </item>
  </channel>
</rss>

