<?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: search start time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69594#M17444</link>
    <description>&lt;P&gt;Isn't the time the search was run equal to now from the search's point of view?&lt;/P&gt;</description>
    <pubDate>Thu, 21 Mar 2013 15:52:20 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2013-03-21T15:52:20Z</dc:date>
    <item>
      <title>search start time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69586#M17436</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;

&lt;P&gt;I would like to know if it's possible in the earliest / latest fields of a search to have something like:&lt;/P&gt;

&lt;P&gt;index=myindex earliest="the time this search has started"-X seconds latest="the time this search has started" -Y seconds&lt;/P&gt;

&lt;P&gt;Is it possible?&lt;/P&gt;

&lt;P&gt;The aim is to run a saved search that populates a summary index, but I need to backfill this index with a search that contains earliest=-20h latest=-10h, but running the search as it is with the fill_summary_index.py command line returns no results because events I need to backfill occurs a long time before -20h (I need to backfill 4 month of datas).&lt;/P&gt;

&lt;P&gt;I think I can have an eval statement that would compute what I want, and then just use where, but it would be very inefficient time wise.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;EDIT&lt;/P&gt;

&lt;P&gt;Thanks to the answers, I found that I can use earliest= [some search | return result] to populate the earliest field to look for data when I want. Problem is that I can't find a way to say:&lt;/P&gt;

&lt;P&gt;earliest=["search that returns the starting scheduled time of this saved search"]&lt;/P&gt;

&lt;P&gt;The keyword 'now' returns the starting time of the search when put inside the earliest field, but it's not what I want, I would like to have the starting SCHEDULED time, not the actual time I run the search.&lt;/P&gt;

&lt;P&gt;I don't know if it's the right way to do it, and if there is another way, I would gladly try it.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:34:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69586#M17436</guid>
      <dc:creator>guilhem</dc:creator>
      <dc:date>2020-09-28T13:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: search start time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69587#M17437</link>
      <description>&lt;P&gt;If you can express your time fields using eval you can do a subsearch for each:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex earliest=[some search | eval earliest=something | return $earliest] latest=[some search | eval latest=something | return $latest] | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Mar 2013 13:00:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69587#M17437</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-03-21T13:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: search start time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69588#M17438</link>
      <description>&lt;P&gt;THAT is awesome, didn't know you could run subsearches after an '=' !!!&lt;/P&gt;

&lt;P&gt;Is it possible to run a subsearch like this: 'eval=[some subsearch]' ? It looks increadibly powerfull and will solve many performance problem that I have. Gonna test it right away.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 13:41:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69588#M17438</guid>
      <dc:creator>guilhem</dc:creator>
      <dc:date>2013-03-21T13:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: search start time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69589#M17439</link>
      <description>&lt;P&gt;I have tried it but I couldn't make it works:&lt;/P&gt;

&lt;P&gt;index=_internal earliest=[ search index=_internal | head 1 | return "-24h"]&lt;BR /&gt;
, also tried:&lt;/P&gt;

&lt;P&gt;index=_internal earliest=[ search index=_internal | head 1 | eval test="-24h" | return test]&lt;/P&gt;

&lt;P&gt;but it always returns:&lt;/P&gt;

&lt;P&gt;Error in 'search' command: Unable to parse the search: Comparator '=' has an invalid term on the left hand side.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:34:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69589#M17439</guid>
      <dc:creator>guilhem</dc:creator>
      <dc:date>2020-09-28T13:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: search start time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69590#M17440</link>
      <description>&lt;P&gt;Peoblem solved, in fact result contained "test=-24h" and not only "-24h" as I was expected.&lt;/P&gt;

&lt;P&gt;The correct search is then:&lt;/P&gt;

&lt;P&gt;index=_internal [search index=_internal | head 1 | eval earliest="-24h" | return earliest]&lt;/P&gt;

&lt;P&gt;which works wonderfully.&lt;/P&gt;

&lt;P&gt;Many thanks for the help.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:34:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69590#M17440</guid>
      <dc:creator>guilhem</dc:creator>
      <dc:date>2020-09-28T13:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: search start time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69591#M17441</link>
      <description>&lt;P&gt;I just need to figure out how to get the time the search was scheduled, instead of the "now" time.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 14:19:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69591#M17441</guid>
      <dc:creator>guilhem</dc:creator>
      <dc:date>2013-03-21T14:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: search start time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69592#M17442</link>
      <description>&lt;P&gt;Your first attempt can be made to work like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=[ stats count | eval test="-24h" | return $test]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The dollar sign changes the behaviour of return, returning only the value itself instead of key=value as usual.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 14:20:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69592#M17442</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-03-21T14:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: search start time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69593#M17443</link>
      <description>&lt;P&gt;nice! Another tip I didn't know.&lt;/P&gt;

&lt;P&gt;I am still trying to find a way to get the search scheduled time start, but I didn't find it yet. Does scheduled search have a special field containing their scheduled time?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 15:47:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69593#M17443</guid>
      <dc:creator>guilhem</dc:creator>
      <dc:date>2013-03-21T15:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: search start time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69594#M17444</link>
      <description>&lt;P&gt;Isn't the time the search was run equal to now from the search's point of view?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 15:52:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69594#M17444</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-03-21T15:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: search start time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69595#M17445</link>
      <description>&lt;P&gt;Thank you very much martin for the help. I finally found the rest of the solution from &lt;A href="http://splunk-base.splunk.com/answers/49539/variables-indicating-the-time-range-of-the-interactive-search-selection" target="_blank"&gt;here&lt;/A&gt;, use | addinfo, and info_min_time to retrieve the starting time of the search. So the final answer is (if you want earliest to start 20 hours before the scheduled time of the search eg):&lt;/P&gt;

&lt;P&gt;index=_internal earliest=[ search index=_internal | head 1| addinfo | eval test=info_min_time-20*3600 | return $test]&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;EDIT&lt;/P&gt;

&lt;P&gt;simplified, optimized, cleaned version:&lt;/P&gt;

&lt;P&gt;index=_internal earliest=[ stats count | addinfo | eval test=relative_time(info_min_time, "-20h") | return $test]&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:34:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69595#M17445</guid>
      <dc:creator>guilhem</dc:creator>
      <dc:date>2020-09-28T13:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: search start time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69596#M17446</link>
      <description>&lt;P&gt;Since you're not actually using any data from _internal you could replace that with a call to stats or something else that doesn't cause any data to be loaded:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=[ stats count | addinfo | eval test=relative_time(info_min_time, "-20h") | return $test]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Additionally, you can let Splunk's relative time syntax do the time fiddling for you in case it gets more complicated.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 16:18:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69596#M17446</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-03-21T16:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: search start time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69597#M17447</link>
      <description>&lt;P&gt;Thank you very much, I have learned a lots of very valuable things on splunk today. It's been a loooong time since I want to find a way to have something evalued whithout pulling datas:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;doesn't work, so I used to play with index=X | head 1 so it was really fast. Yours (using stats) is even better.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Never used relative_time before. It's really clean and less "hacky" than what I did. I update the answer&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 16:24:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-start-time/m-p/69597#M17447</guid>
      <dc:creator>guilhem</dc:creator>
      <dc:date>2013-03-21T16:24:59Z</dc:date>
    </item>
  </channel>
</rss>

