<?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: How to add dynamic timewrap to dashboard? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/606951#M211048</link>
    <description>&lt;P&gt;The order in the XML file is not significant, i.e. the global &amp;lt;search&amp;gt; would normally be at the top of the XML anyway.&lt;/P&gt;&lt;P&gt;If your fieldset input has a token input_time then this will be available to the search - do you have 'search when changed' on the input?&lt;/P&gt;&lt;P&gt;To diagnose tokens, you can create a simple HTML panel that shows the token values, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;row&amp;gt;
  &amp;lt;panel&amp;gt;
    &amp;lt;html&amp;gt;
&amp;lt;h1&amp;gt;earliest=$earliest$&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;latest=$latest$&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;timewrap_earliest=$timewrap_earliest$&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;timewrap_latest=$timewrap_latest$&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;input_time.earliest=$input_time.earliest$&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;input_time.latest=$input_time.latest$&amp;lt;/h1&amp;gt;
    &amp;lt;/html&amp;gt;
  &amp;lt;/panel&amp;gt;
&amp;lt;/row&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;this should show you what is going on as you change the time picker setting&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jul 2022 22:56:03 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2022-07-25T22:56:03Z</dc:date>
    <item>
      <title>How to add dynamic timewrap to dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/606239#M210837</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to be able to have&amp;nbsp; a dynamic timewrap option on my dashboard. Based on the user input (of specific time range and a time wrap variable), i want some graphs on the dashboard to plot the events from that entered time range and also the events from the day before/ week before, based on the timewrap variable. Is this doable?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached some messy code; not sure if this is doable. Thank you for your advice!&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SplunkQ.JPG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20591i16DA45F196683A38/image-size/large?v=v2&amp;amp;px=999" role="button" title="SplunkQ.JPG" alt="SplunkQ.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 21:00:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/606239#M210837</guid>
      <dc:creator>SShalaka</dc:creator>
      <dc:date>2022-07-19T21:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic timewrap to dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/606243#M210841</link>
      <description>&lt;P&gt;You can't use variables from the top part of the search in the append subsearch.&amp;nbsp; Subsearches run before the main search.&lt;/P&gt;&lt;P&gt;The solution is to do the earliest and latest calculations in a global search in the dashboard that is triggered from the user input and then set tokens based on that result in its &amp;lt;done&amp;gt; clause. Then those tokens can be used in this main search, which would then look something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* other_criteria ((earliest=$earliest$ latest=$latest$) OR (earliest=$timewrap_earliest$ latest=$timewrap_latest$))
| rex...
| timechart...&lt;/LI-CODE&gt;&lt;P&gt;Global search could look something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search&amp;gt;
  &amp;lt;query&amp;gt;
| makeresults
| eval earliest=calc_earliest...
| eval latest=calc_latest...
| eval timewrap_earliest=calc_timewrap_earliest...
| eval timewrap_latest=calc_timewrap_latest...
  &amp;lt;/query&amp;gt;
  &amp;lt;done&amp;gt;
    &amp;lt;set token="earliest"&amp;gt;$result.earliest$&amp;lt;/set&amp;gt;
    &amp;lt;set token="latest"&amp;gt;$result.latest$&amp;lt;/set&amp;gt;
    &amp;lt;set token="timewrap_earliest"&amp;gt;$result.timewrap_earliest$&amp;lt;/set&amp;gt;
    &amp;lt;set token="timewrap_latest"&amp;gt;$result.timewrap_latest$&amp;lt;/set&amp;gt;
  &amp;lt;/done&amp;gt;
&amp;lt;/search&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 22:19:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/606243#M210841</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-07-19T22:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic timewrap to dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/606244#M210842</link>
      <description>&lt;P&gt;oh, and as for the 'wrapping', instead of adding _time to bring it in line with the current search, just use the timewrap command, which does that for you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 22:20:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/606244#M210842</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-07-19T22:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic timewrap to dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/606941#M211046</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;thanks so much for taking the time to reply to my message, I am grateful. I have been messing around with the code but keep getting stuck at one point. I took your advice and created a global search, but since this base search needs to run based off a user input, it does not seem to work for me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I put this search below the fieldset, it just automatically jumps to the top when I save the dashboard, and hence does not have access to the input values from the user. Is there something obvious I am missing or is there a solution for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="splunkQ2.JPG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20679i4755375BABC9CE05/image-size/large?v=v2&amp;amp;px=999" role="button" title="splunkQ2.JPG" alt="splunkQ2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 19:46:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/606941#M211046</guid>
      <dc:creator>SShalaka</dc:creator>
      <dc:date>2022-07-25T19:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic timewrap to dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/606951#M211048</link>
      <description>&lt;P&gt;The order in the XML file is not significant, i.e. the global &amp;lt;search&amp;gt; would normally be at the top of the XML anyway.&lt;/P&gt;&lt;P&gt;If your fieldset input has a token input_time then this will be available to the search - do you have 'search when changed' on the input?&lt;/P&gt;&lt;P&gt;To diagnose tokens, you can create a simple HTML panel that shows the token values, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;row&amp;gt;
  &amp;lt;panel&amp;gt;
    &amp;lt;html&amp;gt;
&amp;lt;h1&amp;gt;earliest=$earliest$&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;latest=$latest$&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;timewrap_earliest=$timewrap_earliest$&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;timewrap_latest=$timewrap_latest$&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;input_time.earliest=$input_time.earliest$&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;input_time.latest=$input_time.latest$&amp;lt;/h1&amp;gt;
    &amp;lt;/html&amp;gt;
  &amp;lt;/panel&amp;gt;
&amp;lt;/row&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;this should show you what is going on as you change the time picker setting&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 22:56:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/606951#M211048</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-07-25T22:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic timewrap to dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/607059#M211093</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;,&amp;nbsp;I have "search when changed" set to false. Does this matter? I tried out the html panel and this is the result I get:&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="splunkQ3.JPG" style="width: 697px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20689iB361F1F4915A8CF5/image-size/large?v=v2&amp;amp;px=999" role="button" title="splunkQ3.JPG" alt="splunkQ3.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;and this is the source:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="splunkQ4.JPG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20690i8A9C9104ED4DDCDB/image-size/large?v=v2&amp;amp;px=999" role="button" title="splunkQ4.JPG" alt="splunkQ4.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Not sure where I am messing up; think I am missing something small..&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 15:31:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/607059#M211093</guid>
      <dc:creator>SShalaka</dc:creator>
      <dc:date>2022-07-26T15:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic timewrap to dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/607104#M211101</link>
      <description>&lt;P&gt;The initial setting of earliest and latest needs to quote the tokens on the right hand side.&lt;/P&gt;&lt;P&gt;Here's an example, where I have put the search inside a panel, so you can see what's going on - you will see that unless you quote the latest=$input_time.latest$, you will get an error in the eval statement&lt;/P&gt;&lt;P&gt;See this example&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Time&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="true" autoRun="false"&amp;gt;
    &amp;lt;input type="time" token="input_time"&amp;gt;
      &amp;lt;label&amp;gt;Incident&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-60m@m&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;input type="text" token="dynamic_time"&amp;gt;
      &amp;lt;label&amp;gt;Dynamic&amp;lt;/label&amp;gt;
      &amp;lt;initialValue&amp;gt;1d&amp;lt;/initialValue&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;set token="earliest"&amp;gt;$result.earliest$&amp;lt;/set&amp;gt;
            &amp;lt;set token="latest"&amp;gt;$result.latest$&amp;lt;/set&amp;gt;
            &amp;lt;set token="timewrap_earliest"&amp;gt;$result.timewrap_earliest$&amp;lt;/set&amp;gt;
            &amp;lt;set token="timewrap_latest"&amp;gt;$result.timewrap_latest$&amp;lt;/set&amp;gt;
          &amp;lt;/done&amp;gt;
          &amp;lt;query&amp;gt;| makeresults
  | eval earliest="$input_time.earliest$"
  | eval latest="$input_time.latest$"
  | eval length=len("$input_time.earliest$")
  | eval earliest_unix=if(length&amp;amp;gt;10, "$input_time.earliest$", relative_time(now(), "$input_time.earliest$"))
  | eval latest_unix=if(length&amp;amp;gt;10, "$input_time.latest$", if("$input_time.latest$"=="now", relative_time(now(), "-0d"), relative_time(now(), "$input_time.latest$")))
  | eval timewrap_earliest=case("$dynamic_time$"=="1d", earliest_unix-86400, "$dynamic_time$"=="1w", earliest_unix-604800)
  | eval timewrap_latest=case("$dynamic_time$"=="1d", latest_unix-86400, "$dynamic_time$"=="1w", latest_unix-604800)
``` For display only ```
| eval eu=strftime(earliest_unix, "%F %T")
| eval lu=strftime(latest_unix, "%F %T")
| eval twe=strftime(timewrap_earliest, "%F %T")
| eval twl=strftime(timewrap_latest, "%F %T")
| table _time earliest latest earliest_unix latest_unix timewrap_earliest timewrap_latest eu lu twe twl&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$latest$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
      &amp;lt;html&amp;gt;
  &amp;lt;h1&amp;gt;earliest=$earliest$&amp;lt;/h1&amp;gt;
  &amp;lt;h1&amp;gt;latest=$latest$&amp;lt;/h1&amp;gt;
  &amp;lt;h1&amp;gt;timewrap_earliest=$timewrap_earliest$&amp;lt;/h1&amp;gt;
  &amp;lt;h1&amp;gt;timewrap_latest=$timewrap_latest$&amp;lt;/h1&amp;gt;
  &amp;lt;h1&amp;gt;input_time.earliest=$input_time.earliest$&amp;lt;/h1&amp;gt;
  &amp;lt;h1&amp;gt;input_time.latest=$input_time.latest$&amp;lt;/h1&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 26 Jul 2022 23:46:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/607104#M211101</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-07-26T23:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to add dynamic timewrap to dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/607272#M211131</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;yes I see where I was wrong. It works perfectly now, thanks so much&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2022 22:53:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-dynamic-timewrap-to-dashboard/m-p/607272#M211131</guid>
      <dc:creator>SShalaka</dc:creator>
      <dc:date>2022-07-27T22:53:49Z</dc:date>
    </item>
  </channel>
</rss>

