<?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 Query running time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367123#M108286</link>
    <description>&lt;P&gt;I want to run a query every 5 minutes starting from today 7 AM to next day 5 AM and so on. Throughout my run earliest time should be 7 AM today and latest can be now.&lt;/P&gt;

&lt;P&gt;I tried several combinations but everything messed up when running over the mid noght. after the 12 00 AM the earliest is becoming invalid. All of the below methods taking earliest time as 7 AM till end of the day. when running after the mid night throwing error saying earliest time should not be greater than latest time.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Try 1
| makeresults | eval starttime=strptime(strftime(now(),"%d/%m/%Y 07:00:00 AM"),"%d/%m/%Y %I:%M:%S %p") , endtime=starttime+7920

Try 2
earliest=@d+7h

Try 3
     | eval now=now() 
     | eval earliest=relative_time(now, "@d+1d+7h") 
     | eval earliest=if((earliest&amp;lt;now), earliest, relative_time(now, "@d+7h")) 
     | eval search = "earliest=" . earliest
     | table search]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 27 Dec 2017 16:56:04 GMT</pubDate>
    <dc:creator>Kwip</dc:creator>
    <dc:date>2017-12-27T16:56:04Z</dc:date>
    <item>
      <title>Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367123#M108286</link>
      <description>&lt;P&gt;I want to run a query every 5 minutes starting from today 7 AM to next day 5 AM and so on. Throughout my run earliest time should be 7 AM today and latest can be now.&lt;/P&gt;

&lt;P&gt;I tried several combinations but everything messed up when running over the mid noght. after the 12 00 AM the earliest is becoming invalid. All of the below methods taking earliest time as 7 AM till end of the day. when running after the mid night throwing error saying earliest time should not be greater than latest time.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Try 1
| makeresults | eval starttime=strptime(strftime(now(),"%d/%m/%Y 07:00:00 AM"),"%d/%m/%Y %I:%M:%S %p") , endtime=starttime+7920

Try 2
earliest=@d+7h

Try 3
     | eval now=now() 
     | eval earliest=relative_time(now, "@d+1d+7h") 
     | eval earliest=if((earliest&amp;lt;now), earliest, relative_time(now, "@d+7h")) 
     | eval search = "earliest=" . earliest
     | table search]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Dec 2017 16:56:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367123#M108286</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2017-12-27T16:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367124#M108287</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search [| makeresults | eval earliest=if(now()&amp;lt;=relative_time(now(),"@d+5h"),"-1d@d+7h","@d+7h") | eval latest="now" | table earliest latest ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Dec 2017 17:08:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367124#M108287</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-12-27T17:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367125#M108288</link>
      <description>&lt;P&gt;Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your base search&amp;gt;
[| makeresults 
| addinfo 
| eval latest=now() 
| eval today_7_am=relative_time(latest, "@d+7h") 
| eval yesterday_7_am=relative_time(latest, "-1d@d+7h") 
| eval earliest=if(today_7_am&amp;lt;latest, today_7_am, yesterday_7_am) 
| table earliest]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That does a simple comparison of your calculated earliest times to determine which was actually in the past, and chooses that one.  &lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 17:20:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367125#M108288</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2017-12-27T17:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367126#M108289</link>
      <description>&lt;P&gt;This seems to be a &lt;A href="https://answers.splunk.com/answers/582477/how-do-i-set-search-start-time-and-end-time-on-das.html"&gt;duplicate&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 18:30:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367126#M108289</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2017-12-27T18:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367127#M108290</link>
      <description>&lt;P&gt;&lt;CODE&gt;index=_internal [| makeresults | eval earliest=if(now()&amp;lt;=relative_time(now(),"@d+5h"),"-1d@d+7h","@d+7h") | eval latest="now" | table earliest latest ]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I tried it and it gave me an error "&lt;EM&gt;Error in 'search' command: Unable to parse the search: 'AND' operator is missing a clause on the left hand side&lt;/EM&gt;."&lt;/P&gt;

&lt;P&gt;How to create new earliest and latest time fields and use them in query &lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 22:55:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367127#M108290</guid>
      <dc:creator>nawazns5038</dc:creator>
      <dc:date>2017-12-27T22:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367128#M108291</link>
      <description>&lt;P&gt;Verifying this query. Working fine now. Will verify over mid night window and let you know the outcome.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 01:23:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367128#M108291</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2017-12-28T01:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367129#M108292</link>
      <description>&lt;P&gt;Verifying this query. Working fine now. Will verify over mid night window and let you know the outcome.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 01:29:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367129#M108292</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2017-12-28T01:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367130#M108293</link>
      <description>&lt;P&gt;@ somesoni2,&lt;BR /&gt;
Wow!! Thank you very much It is working fine!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 06:15:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367130#M108293</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2017-12-28T06:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367131#M108294</link>
      <description>&lt;P&gt;@ micahkemp,&lt;BR /&gt;
Wow!! Thank you very much It is working fine!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 06:16:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367131#M108294</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2017-12-28T06:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367132#M108295</link>
      <description>&lt;P&gt;How did you verify ? &lt;/P&gt;

&lt;P&gt;How did you use the earliest and latest time fields created by the query into _time of Splunk. &lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 22:00:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367132#M108295</guid>
      <dc:creator>nawazns5038</dc:creator>
      <dc:date>2017-12-28T22:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367133#M108296</link>
      <description>&lt;P&gt;@nawazns5038&lt;BR /&gt;
You no need anything else apart from adding the particular portion in the query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search 
[| makeresults 
| eval earliest=if(now()&amp;lt;=relative_time(now(),"@d+5h"),"-1d@d+7h","@d+7h") 
| eval latest="now" 
| table earliest latest ]
| stats/eval/table/or whatever operation you want to perform.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;While running this query, running span will be automatically taken from this query.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2017 01:28:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367133#M108296</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2017-12-29T01:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367134#M108297</link>
      <description>&lt;P&gt;@somesoni2&lt;BR /&gt;
I am getting below error while using this query after the splunk upgrade to 7.0. Any thoughts?&lt;/P&gt;

&lt;P&gt;Error in 'search' command: Unable to parse the search: 'AND' operator is missing a clause on the left hand side.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 21:04:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367134#M108297</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2018-08-02T21:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367135#M108298</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search 
 [| makeresults 
 | eval earliest=if(now()&amp;lt;=relative_time(now(),"@d+5h"),"-1d@d+7h","@d+7h") 
 | eval latest="now" 
 | table earliest latest | format ]
 | stats/eval/table/or whatever operation you want to perform.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search 
 [| makeresults 
 | eval earliest=if(now()&amp;lt;=relative_time(now(),"@d+5h"),"-1d@d+7h","@d+7h") 
 | eval latest="now" 
 | table earliest latest  | format "" "" "" "" "" ""]
 | stats/eval/table/or whatever operation you want to perform.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Aug 2018 23:17:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367135#M108298</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-08-02T23:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: Query running time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367136#M108299</link>
      <description>&lt;P&gt;Thank you @somesoni2, It is working fine.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2018 18:08:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-running-time/m-p/367136#M108299</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2018-08-03T18:08:52Z</dc:date>
    </item>
  </channel>
</rss>

