<?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: time picker in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299941#M163779</link>
    <description>&lt;P&gt;Hi micahkemp&lt;/P&gt;

&lt;P&gt;This is what i have - which errors with invalid earliest time.&lt;/P&gt;

&lt;P&gt;SM_Test&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt;
  &amp;lt;![CDATA[| makeresults | addinfo | eval earliest7=info_min_time-7*24*3600, latest7=if(info_max_time="+Infinity", now()-7*24*3600, info_max_time-7*24*3600)]]&amp;gt;
&amp;lt;/query&amp;gt;
&amp;lt;done&amp;gt;
  &amp;lt;condition match="'job.resultCount' == 1"&amp;gt;
    &amp;lt;set token="earliest7"&amp;gt;$result.earliest7$&amp;lt;/set&amp;gt;
    &amp;lt;set token="latest7"&amp;gt;$result.latest7$&amp;lt;/set&amp;gt;
  &amp;lt;/condition&amp;gt;
&amp;lt;/done&amp;gt;


&amp;lt;input type="time" token="field1" searchWhenChanged="true"&amp;gt;
  &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
  &amp;lt;default&amp;gt;
    &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
  &amp;lt;/default&amp;gt;
&amp;lt;/input&amp;gt;


&amp;lt;panel&amp;gt;
  &amp;lt;table&amp;gt;
    &amp;lt;title&amp;gt;xyz&amp;lt;/title&amp;gt;
    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;host="xxx-xxx-xxx" sourcetype="alarm_metric"  |spath "Message.SourceApp" | search "Message.SourceApp"=xyz | eval spath='Message.EventMessage' | rex field=spath "took (?P&amp;amp;lt;elapsed&amp;amp;gt;\S+)" | eval elapsed = elapsed/1000 | table _time spath, host elapsed | eval ReportKey="This Time 7 Days Ago"  | append [search host="xxx-xxx-xxx" sourcetype="alarm_metric" $earliest$ $latest$ | spath "Message.SourceApp" | search "Message.SourceApp"=xyz | eval spath='Message.EventMessage' | rex field=spath "took (?P&amp;amp;lt;elapsed&amp;amp;gt;\S+)" | eval elapsed = elapsed/1000 | table _time spath, host elapsed | eval ReportKey="Today"] | chart count by elapsed span=1 ReportKey&amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;$earliest7$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$latest7$&amp;lt;/latest&amp;gt;
    &amp;lt;/search&amp;gt;
    &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Sean&lt;/P&gt;</description>
    <pubDate>Sat, 13 Jan 2018 09:47:03 GMT</pubDate>
    <dc:creator>seanmylne</dc:creator>
    <dc:date>2018-01-13T09:47:03Z</dc:date>
    <item>
      <title>time picker</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299932#M163770</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;

&lt;P&gt;I am trying to show 2 tables - one for the time frame using a time-picker and one search for the same time frame but for 7 days ago.&lt;/P&gt;

&lt;P&gt;Below is my query using field1 as my time picker.&lt;/P&gt;

&lt;P&gt;Below is my "query" in my dashboard.&lt;/P&gt;

&lt;P&gt;host="xxx-xxx-xxx" sourcetype="alarm_metric" ealiest=$field1.earliest$-86400m latest=$field1.ealiest$-86385m&lt;BR /&gt;
| spath "Message.SourceApp" | search "Message.SourceApp"=xxxx | eval spath='Message.EventMessage' | rex field=spath "took (?P&amp;lt;elapsed&amp;gt;\S+)" &lt;BR /&gt;
| eval elapsed = elapsed/1000 | table _time spath, host elapsed | eval ReportKey="This Time 7 Days Ago" | append [search host="xxx-xxx-xxx" sourcetype="alarm_metric" earliest=$field1.earliest$ latest=$field1.latest$ &lt;BR /&gt;
| spath "Message.SourceApp" | search "Message.SourceApp"=xxxx | eval spath='Message.EventMessage' | rex field=spath "took (?P&amp;lt;elapsed&amp;gt;\S+)" | eval elapsed = elapsed/1000 | table _time spath, host elapsed &lt;BR /&gt;
| eval ReportKey="Today"] | chart count by elapsed span=1 ReportKey&lt;/P&gt;

&lt;P&gt;I am using count and not timechart so cannot use timewrap as i want to show a count of response times 0-1, 2-3 and so on.&lt;/P&gt;

&lt;P&gt;Thanks &lt;BR /&gt;
Sean&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:36:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299932#M163770</guid>
      <dc:creator>seanmylne</dc:creator>
      <dc:date>2020-09-29T17:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: time picker</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299933#M163771</link>
      <description>&lt;P&gt;It seems to be a number of problems with &lt;CODE&gt;earliest=$field1.earliest$-86400m  latest=$field1.ealiest$-86385m&lt;/CODE&gt;. First of all, you cannot subtract "86400m", because Splunk holds "86400m" as a string. It's better to use &lt;CODE&gt;earliest=$field1.earliest$-86400&lt;/CODE&gt;, without "m". Second, if you want to get "This Time 7 Days Ago", you should subtract 7*24*3600 = 604800, rather than 86400. At last, this notation fails if you select relative time in your initial time picker. In this case &lt;CODE&gt;$field1.earliest$&lt;/CODE&gt; equals to "-15m" or smth like that and it will be difficult to count "-15m-604800".&lt;/P&gt;

&lt;P&gt;You can try the following workaround. Add a search on your dashboard with this query: &lt;BR /&gt;
&lt;PRE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;| makeresults | addinfo | eval earliest7=info_min_time-7*24*3600, latest7=if(info_max_time="+Infinity", now()-7*24*3600, info_max_time-7*24*3600)&lt;/P&gt;

&lt;P&gt;$field1.earliest$&lt;BR /&gt;
  $field1.latest$&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;set token="earliest7"&amp;gt;$result.earliest7$&amp;lt;/set&amp;gt;
&amp;lt;set token="latest7"&amp;gt;$result.latest7$&amp;lt;/set&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Then use tokens &lt;CODE&gt;$field1.earliest$&lt;/CODE&gt; and &lt;CODE&gt;field1.latest&lt;/CODE&gt; as earliest and latest bounds in "today" subsearch and use tokens &lt;CODE&gt;$earliest7$&lt;/CODE&gt; and &lt;CODE&gt;$latest7$&lt;/CODE&gt; as earliest and latest bounds in "7 days ago" subsearch.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:32:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299933#M163771</guid>
      <dc:creator>nryabykh</dc:creator>
      <dc:date>2020-09-29T17:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: time picker</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299934#M163772</link>
      <description>&lt;P&gt;Hi Nryabykh,&lt;/P&gt;

&lt;P&gt;Thanks for the reply. tbh i tried it with and without the m and could not get it to play &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I have also tried to add your suggestions but without success. I have added my panel and start  of the form:-&lt;/P&gt;

&lt;P&gt;SM_Test&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="time" token="field1" searchWhenChanged="true"&amp;gt;
  &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
  &amp;lt;default&amp;gt;
    &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
  &amp;lt;/default&amp;gt;
&amp;lt;/input&amp;gt;

&amp;lt;init&amp;gt;
  &amp;lt;set token="earliest7"&amp;gt;$result.$earliest7$&amp;lt;/set&amp;gt;
  &amp;lt;set token="latest7"&amp;gt;$result.$latest7$&amp;lt;/set&amp;gt;
&amp;lt;/init&amp;gt;

&amp;lt;panel&amp;gt;
  &amp;lt;table&amp;gt;
    &amp;lt;title&amp;gt;Test App&amp;lt;/title&amp;gt;
    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;makeresults | addinfo | eval earliest7=info_min_time-7*24*3600, latest7=if(info_max_time="+Infinity", now()-7*24*3600, info_max_time-7*24*3600) 
      host="xxx-xxx-xxx" sourcetype="alarm_metric" earliest=earliest7$ latest=latest7$ | spath "Message.SourceApp" | search "Message.SourceApp"=xxxx 
      | eval spath='Message.EventMessage' | rex field=spath "took (?P&amp;amp;lt;elapsed&amp;amp;gt;\S+)" | eval elapsed = elapsed/1000 
      | table _time spath, host elapsed | eval ReportKey="This Time 7 Days Ago"  | append [search host="xxx-xxx-xxx" sourcetype="alarm_metric" earliest=$field1.earliest$ latest=$field1.latest$ 
      | spath "Message.SourceApp" | search "Message.SourceApp"=xxxx | eval spath='Message.EventMessage' | rex field=spath "took (?P&amp;amp;lt;elapsed&amp;amp;gt;\S+)" | eval elapsed = elapsed/1000 
      | table _time spath, host elapsed | eval ReportKey="Today"] | chart count by elapsed span=1 ReportKey&amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;$field1.earliest$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$field1.latest$&amp;lt;/latest&amp;gt;
    &amp;lt;/search&amp;gt;
    &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using the above i get an error stating "Search is waiting for input...."&lt;/P&gt;

&lt;P&gt;Not sure where i am going wrong.&lt;/P&gt;

&lt;P&gt;Thanks &lt;BR /&gt;
Sean&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 21:37:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299934#M163772</guid>
      <dc:creator>seanmylne</dc:creator>
      <dc:date>2018-01-10T21:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: time picker</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299935#M163773</link>
      <description>&lt;P&gt;The previous answer wanted you to have two searches, one for your panel, one that is separate from any panel and really just sets the tokens.  For your panel search, something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;       &amp;lt;query&amp;gt;host="xxx-xxx-xxx" sourcetype="alarm_metric" | spath "Message.SourceApp" | search "Message.SourceApp"=xxxx 
       | eval spath='Message.EventMessage' | rex field=spath "took (?P&amp;lt;elapsed&amp;gt;\S+)" | eval elapsed = elapsed/1000 
       | table _time spath, host elapsed | eval ReportKey="This Time 7 Days Ago"  | append [search host="xxx-xxx-xxx" sourcetype="alarm_metric"
       | spath "Message.SourceApp" | search "Message.SourceApp"=xxxx | eval spath='Message.EventMessage' | rex field=spath "took (?P&amp;lt;elapsed&amp;gt;\S+)" | eval elapsed = elapsed/1000 
       | table _time spath, host elapsed | eval ReportKey="Today"] | chart count by elapsed span=1 ReportKey&amp;lt;/query&amp;gt;
       &amp;lt;earliest&amp;gt;$earliest7$&amp;lt;/earliest&amp;gt;
       &amp;lt;latest&amp;gt;$latest7$&amp;lt;/latest&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note I moved &lt;CODE&gt;$earliest7$&lt;/CODE&gt; and &lt;CODE&gt;$latest7$&lt;/CODE&gt; out of the search string and into the earliest/latest fields below. But if you do need to use a token in a search string, you need to make sure it's surrounded by &lt;CODE&gt;$&lt;/CODE&gt; (on both sides).  Your pasted XML had some instances of &lt;CODE&gt;$&lt;/CODE&gt; on only one side of the token name.&lt;/P&gt;

&lt;P&gt;And then another search higher up in the dashboard to set the tokens:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;search id="set_time"&amp;gt;
     &amp;lt;query&amp;gt;&amp;lt;![CDATA[| makeresults | addinfo | eval earliest7=info_min_time-7*24*3600, latest7=if(info_max_time="+Infinity", now()-7*24*3600, info_max_time-7*24*3600)]]&amp;gt;&amp;lt;/query&amp;gt;
     &amp;lt;done&amp;gt;
       &amp;lt;condition match="'job.resultCount' == 1"&amp;gt;
          &amp;lt;set token="earliest7"&amp;gt;$result.earliest7$&amp;lt;/set&amp;gt;
          &amp;lt;set token="latest7"&amp;gt;$result.latest7$&amp;lt;/set&amp;gt;
       &amp;lt;/condition&amp;gt;
     &amp;lt;/done&amp;gt;
   &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Consider referencing this &lt;A href="https://answers.splunk.com/answers/608999/modifying-an-input-for-dashboard-change-a-time-for.html#answer-609973"&gt;recent answer&lt;/A&gt; I posted regarding how this may look as a complete XML example.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 05:02:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299935#M163773</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-11T05:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: time picker</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299936#M163774</link>
      <description>&lt;P&gt;Hi, Sean.&lt;BR /&gt;
Sorry for bad formatting in my answer, I was confused a bit about text input controls here. Micahkemp represented it clearly in the answer below.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 10:19:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299936#M163774</guid>
      <dc:creator>nryabykh</dc:creator>
      <dc:date>2018-01-11T10:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: time picker</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299937#M163775</link>
      <description>&lt;P&gt;If your question was answered, please accept the answer you consider most valid/helpful, so this answer no longer appears open.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 15:27:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299937#M163775</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-11T15:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: time picker</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299938#M163776</link>
      <description>&lt;P&gt;Hi nyabykh,&lt;/P&gt;

&lt;P&gt;Even with it explained a little bit more i can not get either to work.  I have tried various permutations of following both advice but either getting waiting for input or invalid start time.&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Sean &lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 17:38:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299938#M163776</guid>
      <dc:creator>seanmylne</dc:creator>
      <dc:date>2018-01-12T17:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: time picker</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299939#M163777</link>
      <description>&lt;P&gt;Hi micahkemp,&lt;/P&gt;

&lt;P&gt;Thanks for the advice. However i can not actually get it work. Not sure what i am missing but i either get invalid start time or waiting for input when i am trying to get it to work.&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Sean&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 17:41:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299939#M163777</guid>
      <dc:creator>seanmylne</dc:creator>
      <dc:date>2018-01-12T17:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: time picker</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299940#M163778</link>
      <description>&lt;P&gt;Can you paste the XML of your dashboard that is not working?&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 05:40:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299940#M163778</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-13T05:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: time picker</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299941#M163779</link>
      <description>&lt;P&gt;Hi micahkemp&lt;/P&gt;

&lt;P&gt;This is what i have - which errors with invalid earliest time.&lt;/P&gt;

&lt;P&gt;SM_Test&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt;
  &amp;lt;![CDATA[| makeresults | addinfo | eval earliest7=info_min_time-7*24*3600, latest7=if(info_max_time="+Infinity", now()-7*24*3600, info_max_time-7*24*3600)]]&amp;gt;
&amp;lt;/query&amp;gt;
&amp;lt;done&amp;gt;
  &amp;lt;condition match="'job.resultCount' == 1"&amp;gt;
    &amp;lt;set token="earliest7"&amp;gt;$result.earliest7$&amp;lt;/set&amp;gt;
    &amp;lt;set token="latest7"&amp;gt;$result.latest7$&amp;lt;/set&amp;gt;
  &amp;lt;/condition&amp;gt;
&amp;lt;/done&amp;gt;


&amp;lt;input type="time" token="field1" searchWhenChanged="true"&amp;gt;
  &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
  &amp;lt;default&amp;gt;
    &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
  &amp;lt;/default&amp;gt;
&amp;lt;/input&amp;gt;


&amp;lt;panel&amp;gt;
  &amp;lt;table&amp;gt;
    &amp;lt;title&amp;gt;xyz&amp;lt;/title&amp;gt;
    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;host="xxx-xxx-xxx" sourcetype="alarm_metric"  |spath "Message.SourceApp" | search "Message.SourceApp"=xyz | eval spath='Message.EventMessage' | rex field=spath "took (?P&amp;amp;lt;elapsed&amp;amp;gt;\S+)" | eval elapsed = elapsed/1000 | table _time spath, host elapsed | eval ReportKey="This Time 7 Days Ago"  | append [search host="xxx-xxx-xxx" sourcetype="alarm_metric" $earliest$ $latest$ | spath "Message.SourceApp" | search "Message.SourceApp"=xyz | eval spath='Message.EventMessage' | rex field=spath "took (?P&amp;amp;lt;elapsed&amp;amp;gt;\S+)" | eval elapsed = elapsed/1000 | table _time spath, host elapsed | eval ReportKey="Today"] | chart count by elapsed span=1 ReportKey&amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;$earliest7$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$latest7$&amp;lt;/latest&amp;gt;
    &amp;lt;/search&amp;gt;
    &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Sean&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 09:47:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299941#M163779</guid>
      <dc:creator>seanmylne</dc:creator>
      <dc:date>2018-01-13T09:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: time picker</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299942#M163780</link>
      <description>&lt;P&gt;Could there be a syntax error with the fact that there are 3 $ in the token setting expression? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$result.$earliest7$
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Nov 2018 21:02:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-picker/m-p/299942#M163780</guid>
      <dc:creator>mstark31</dc:creator>
      <dc:date>2018-11-27T21:02:32Z</dc:date>
    </item>
  </channel>
</rss>

