<?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 base search in drop down list in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508072#M33787</link>
    <description>To prevent a search from running until the user has made a selection, include an input token in that search.</description>
    <pubDate>Wed, 08 Jul 2020 12:44:44 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-07-08T12:44:44Z</dc:date>
    <item>
      <title>Using base search in drop down list</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508041#M33781</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;We're newbie to Splunk app development and using Splunk 7.3.5.&lt;/P&gt;&lt;P&gt;We wrote a testing app&amp;nbsp; based on sample here &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.5/Viz/Buildandeditforms," target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.5/Viz/Buildandeditforms,&lt;/A&gt; with a time picker and a drop down list which is populated from the base search.&lt;/P&gt;&lt;P&gt;We think the app will not do anything except populating the drop down list, until user select both time range and choice in the drop down list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it doesn't work as expected.&amp;nbsp;&amp;nbsp; When the page is loaded:&lt;/P&gt;&lt;P&gt;- The drop down list keeps showing Populating...&amp;nbsp; for long time (usually the same search returns within 1 minute).&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Then shows "Search produced no results" at end.&lt;/P&gt;&lt;P&gt;- The searches in panel start to run&amp;nbsp; when the page is loaded even before any user input.&amp;nbsp; The search picks the default value in drop down list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We tried to use full search instead of base search, the app works as expected.&lt;/P&gt;&lt;P&gt;We must missed something in the code.&amp;nbsp;&amp;nbsp;&amp;nbsp; Would anyone please help?&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;WWW Statistics &amp;lt;/label&amp;gt;
  &amp;lt;description&amp;gt;WWW statistics (department, browser information)&amp;lt;/description&amp;gt;
  &amp;lt;search id="baseSearch"&amp;gt;
      &amp;lt;query&amp;gt;
         &amp;lt;![CDATA[index=application host="landing.itsc.cuhk.edu.hk" sourcetype=access_combined POST OR GET status&amp;lt;400 | rex field=uri "\/(?&amp;lt;deptcode&amp;gt;[^\/]+)\/" 
         ]]&amp;gt;
      &amp;lt;/query&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;fieldset submitButton="false" autoRun="true"&amp;gt;
    &amp;lt;input type="time"&amp;gt;
      &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-1d@d&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="dropdown" token="d_name" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Select a department&amp;lt;/label&amp;gt;
      &amp;lt;search base="baseSearch"&amp;gt;
        &amp;lt;query&amp;gt;
          fields deptcode  | stats count by deptcode
        &amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;deptcode&amp;lt;/fieldForLabel&amp;gt;splu
      &amp;lt;fieldForValue&amp;gt;deptcode&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;choice value="*"&amp;gt;All&amp;lt;/choice&amp;gt;
      &amp;lt;default&amp;gt;*&amp;lt;/default&amp;gt;
      &amp;lt;initialValue&amp;gt;*&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;title&amp;gt;Access rate for department $d_name$&amp;lt;/title&amp;gt;
      &amp;lt;chart&amp;gt;
        &amp;lt;search base="baseSearch"&amp;gt;
          &amp;lt;query&amp;gt; fields deptcode useragent| search deptcode=$d_name$ | timechart count&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/chart&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Time distribution of browser for department $d_name$&amp;lt;/title&amp;gt;
      &amp;lt;chart&amp;gt;
        &amp;lt;search base="baseSearch"&amp;gt;
          &amp;lt;query&amp;gt; fields deptcode useragent | search deptcode=$d_name$ | rename useragent as http_user_agent | lookup user_agents http_user_agent | timechart count by ua_family usenull=f useother=f&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/chart&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Browser distribution&amp;lt;/title&amp;gt;
      &amp;lt;chart&amp;gt;
        &amp;lt;search base="searchBase"&amp;gt;
          &amp;lt;query&amp;gt; fields deptcode useragent | search deptcode=$d_name$ |  rename useragent as http_user_agent | lookup user_agents http_user_agent |stats count by ua_family&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="charting.chart"&amp;gt;pie&amp;lt;/option&amp;gt;
      &amp;lt;/chart&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Total access for department $d_name$ between $fromDate$ and $toDate$&amp;lt;/title&amp;gt;
        &amp;lt;search base="baseSearch"&amp;gt;
          &amp;lt;query&amp;gt;
            fields deptcode useragent | search deptcode=$d_name$ |stats count
          &amp;lt;/query&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;eval token="Tearliest"&amp;gt;strftime($baseSearch1.info_min_time$,"%F %T")&amp;lt;/eval&amp;gt;
            &amp;lt;eval token="Tlatest"&amp;gt;strftime($baseSearch1.info_max_time$,"%F %T")&amp;lt;/eval&amp;gt;
            &amp;lt;eval token="fromDate"&amp;gt;strftime($earliest$,"%Y%m/%d %H:%M:%S")&amp;lt;/eval&amp;gt;
            &amp;lt;eval token="toDate"&amp;gt;strftime($latest$, "%Y%m/%d %H:%M:%S")&amp;lt;/eval&amp;gt;
          &amp;lt;/done&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2020 11:06:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508041#M33781</guid>
      <dc:creator>stwong</dc:creator>
      <dc:date>2020-07-08T11:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using base search in drop down list</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508072#M33787</link>
      <description>To prevent a search from running until the user has made a selection, include an input token in that search.</description>
      <pubDate>Wed, 08 Jul 2020 12:44:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508072#M33787</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-07-08T12:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using base search in drop down list</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508074#M33788</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/148178"&gt;@stwong&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;There are some errors:&lt;/P&gt;&lt;P&gt;in base search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;query&amp;gt;
    index=application host="landing.itsc.cuhk.edu.hk" sourcetype=access_combined (POST OR GET) status&amp;lt;400 | rex field=uri "\/(?&amp;lt;deptcode&amp;gt;[^\/]+)\/" 
&amp;lt;/query&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;the initial part "&amp;lt;![CDATA[..." it's for drilldown!&lt;/P&gt;&lt;P&gt;but the main problem is that you didn't inserted the time token in the base search:&lt;/P&gt;&lt;P&gt;it's missing the time tokan name in the Time input&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    &amp;lt;input type="time" token="Time"&amp;gt;
      &amp;lt;label&amp;gt;periodo&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-1d@d&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;&lt;/LI-CODE&gt;&lt;P&gt;and the time borders in the base search are missing:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  &amp;lt;search id="baseSearch"&amp;gt;
      &amp;lt;query&amp;gt;
         index=application host="landing.itsc.cuhk.edu.hk" sourcetype=access_combined POST OR GET status&amp;lt;400 | rex field=uri "\/(?&amp;lt;deptcode&amp;gt;[^\/]+)\/" 
      &amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;$Time.earliest$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$Time.latest$&amp;lt;/latest&amp;gt;
  &amp;lt;/search&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;for this reason it's so slow, because it searches on all the time!&lt;/P&gt;&lt;P&gt;For more infos about inputs see in the Splunk Dashboard Examples App (&lt;A href="https://splunkbase.splunk.com/app/1603/" target="_blank"&gt;https://splunkbase.splunk.com/app/1603/&lt;/A&gt;) how to populate a dropdown and how to use it.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2020 12:53:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508074#M33788</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-07-08T12:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using base search in drop down list</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508206#M33797</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/148178"&gt;@stwong&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In addition to the other comments, I suspect your issue may be because non transforming base searches require a&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fields a b c &lt;/LI-CODE&gt;&lt;P&gt;statement at the end of the search, otherwise it may not return any fields.&lt;/P&gt;&lt;P&gt;See the 'Best practices' section here for a discussion on that.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.4/Viz/Savedsearches" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.4/Viz/Savedsearches&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2020 23:45:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508206#M33797</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-07-08T23:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using base search in drop down list</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508223#M33798</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp; thanks a lot for all of your help.&lt;/P&gt;&lt;P&gt;Fixed the base search issue after adding the time token.&lt;/P&gt;&lt;P&gt;Since we defined submitButton to no/false,&amp;nbsp; the base search runs automatically as autoRun=true is implied.&lt;/P&gt;&lt;P&gt;Seems we need to set submitButton to true in order to stop the search from running before user selecting the time range.&lt;/P&gt;&lt;P&gt;We modified the fieldset as following and hope to achieve:&lt;/P&gt;&lt;P&gt;1. on page load: populate the drop down list with default time range.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. before user input (time and department), searches in panels will not run automatically.&lt;/P&gt;&lt;P&gt;3. if user select a different time range, the drop down list will populate again.&lt;/P&gt;&lt;P&gt;4. if user select a department and press submit botton,&amp;nbsp; searches in panels will run accordingly with current time range selected (or default if not changed by users).&lt;/P&gt;&lt;P&gt;but seems points 3 and 4 don't work as expected.&lt;/P&gt;&lt;P&gt;Is there anything missed?&amp;nbsp;&amp;nbsp; Thanks.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  &amp;lt;fieldset submitButton="yes" autoRun="false"&amp;gt;
    &amp;lt;input type="time" token="Time" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-1d@d&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="dropdown" token="d_name" searchWhenChanged="false"&amp;gt;
      &amp;lt;label&amp;gt;Select a department&amp;lt;/label&amp;gt;
      &amp;lt;search base="baseSearch"&amp;gt;
        &amp;lt;query&amp;gt;
          fields deptcode | stats count by deptcode
        &amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;deptcode&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;deptcode&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;choice value="*"&amp;gt;All&amp;lt;/choice&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Btw, we hope to speed up the dashboard,&amp;nbsp; can we accelerate a report with the base search ?&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2020 02:52:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508223#M33798</guid>
      <dc:creator>stwong</dc:creator>
      <dc:date>2020-07-09T02:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using base search in drop down list</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508227#M33799</link>
      <description>&lt;P&gt;You can use a saved search as a base search with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search id="baseSearch" ref="savedSearch"/&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for re-triggering searches to run, I use a token in the search that when the token value changes, will result in the search rerunning. I typically do with with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;init&amp;gt;
  &amp;lt;set token="trigger"&amp;gt;0&amp;lt;/set&amp;gt;
&amp;lt;/init&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then in the place where I want to trigger the search to run again, this could be a &amp;lt;change&amp;gt; condition or a &amp;lt;done&amp;gt; clause of a search, and do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;eval token="trigger"&amp;gt;$trigger$+1&amp;lt;/eval&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;The search will then have&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search depends="$trigger$"&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2020 03:41:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-base-search-in-drop-down-list/m-p/508227#M33799</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-07-09T03:41:25Z</dc:date>
    </item>
  </channel>
</rss>

