<?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 How to create dropdown &amp;quot;all&amp;quot; from dynamic search results? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dropdown-quot-all-quot-from-dynamic-search-results/m-p/641437#M52376</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a dropdown which runs a search query that returns a subset of potential results. I want to create an "ALL" value option which only applies the results of the subset from that search.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;    &amp;lt;input type="dropdown" token="mytoken"&amp;gt;
      &amp;lt;label&amp;gt;My Token&amp;lt;/label&amp;gt;
      &amp;lt;choice value="*"&amp;gt;ALL&amp;lt;/choice&amp;gt;
      &amp;lt;initialValue&amp;gt;*&amp;lt;/initialValue&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;resultName&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;resultValue&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;
          index="AnIndex" type="FilterType"
        &amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
    &amp;lt;/input&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This token is used in a panel as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;    &amp;lt;panel&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Warnings&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;
            index="AnIndex" myToken=$mytoken$ level="warn" | stats count(message)
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
        ...
    &amp;lt;/panel&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;As it currently is, the default value for the dropdown resolves to the wildcard `*`. I want the default value to only be the subset that my query returns.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help appreciated, thank you.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Apr 2023 15:22:29 GMT</pubDate>
    <dc:creator>cclva</dc:creator>
    <dc:date>2023-04-26T15:22:29Z</dc:date>
    <item>
      <title>How to create dropdown "all" from dynamic search results?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dropdown-quot-all-quot-from-dynamic-search-results/m-p/641437#M52376</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a dropdown which runs a search query that returns a subset of potential results. I want to create an "ALL" value option which only applies the results of the subset from that search.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;    &amp;lt;input type="dropdown" token="mytoken"&amp;gt;
      &amp;lt;label&amp;gt;My Token&amp;lt;/label&amp;gt;
      &amp;lt;choice value="*"&amp;gt;ALL&amp;lt;/choice&amp;gt;
      &amp;lt;initialValue&amp;gt;*&amp;lt;/initialValue&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;resultName&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;resultValue&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;
          index="AnIndex" type="FilterType"
        &amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
    &amp;lt;/input&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This token is used in a panel as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;    &amp;lt;panel&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Warnings&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;
            index="AnIndex" myToken=$mytoken$ level="warn" | stats count(message)
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
        ...
    &amp;lt;/panel&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;As it currently is, the default value for the dropdown resolves to the wildcard `*`. I want the default value to only be the subset that my query returns.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help appreciated, thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 15:22:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dropdown-quot-all-quot-from-dynamic-search-results/m-p/641437#M52376</guid>
      <dc:creator>cclva</dc:creator>
      <dc:date>2023-04-26T15:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: Dropdown "all" from dynamic search results</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dropdown-quot-all-quot-from-dynamic-search-results/m-p/641447#M52379</link>
      <description>&lt;P&gt;Seeing you specifically want the subset filtered, using a wildcard will not help narrow anything down. Bit of a workaround, but maybe the following helps achieving your goal:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Change the initial value to an empty value&lt;/LI&gt;&lt;LI&gt;Filter your search by applying your sub-search&lt;/LI&gt;&lt;LI&gt;Apply the filter field when selected&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;So, something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;..
&amp;lt;initialValue&amp;gt;&amp;lt;/initialValue&amp;gt;
&amp;lt;choice value=""&amp;gt;All&amp;lt;/choice&amp;gt;
..&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;query&amp;gt;
  index="AnIndex" level="warn" 
  ``` Filter by applying a subsearch ```
  | search [ | search index="AnIndex" type="FilterType" | fields resultValue ]
  ``` Filter again when $mytoken$ is not empty and matches myToken ```
  | where len("$mytoken$")=0 OR myToken="$mytoken$"
  | stats count(message)
&amp;lt;/query&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 14:35:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dropdown-quot-all-quot-from-dynamic-search-results/m-p/641447#M52379</guid>
      <dc:creator>rut</dc:creator>
      <dc:date>2023-04-26T14:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dropdown "all" from dynamic search results</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dropdown-quot-all-quot-from-dynamic-search-results/m-p/641456#M52380</link>
      <description>&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;This looks like it will work, but my dropdown search has a pretty high response time, so I would want to extract that out. I would expect this solution to have to run the inner search multiple times, and I have a lot of panels that use this token.&lt;/P&gt;&lt;P&gt;Inspired me though, would it be possible to write something for the initial value that groups up all the values together, and I can use something like `token in ($mytoken$)`?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 14:43:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dropdown-quot-all-quot-from-dynamic-search-results/m-p/641456#M52380</guid>
      <dc:creator>cclva</dc:creator>
      <dc:date>2023-04-26T14:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Dropdown "all" from dynamic search results</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dropdown-quot-all-quot-from-dynamic-search-results/m-p/641462#M52382</link>
      <description>&lt;P&gt;&lt;STRIKE&gt;I’m not sure if that type of grouping could work. &lt;/STRIKE&gt;Edit; tested it to be sure. You can use the IN operator with search, but not with where (&lt;A href="https://docs.splunk.com/Documentation/SCS/current/SearchReference/SearchCommandExamples#4._Using_the_IN_operator" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/SCS/current/SearchReference/SearchCommandExamples#4._Using_the_IN_operator&lt;/A&gt;). Because the "len" command the above suggestion uses where.&lt;/P&gt;&lt;P&gt;Depending on if the data needs to be live you could try scheduling the sub search into a lookup or chain searches using the id and base attribute.&lt;/P&gt;&lt;P&gt;About the chain searches, if performance is an issue &lt;EM&gt;and&lt;/EM&gt; your dashboard panels use the same data source, you could ensure the heavy duty stuff only happens on page load by doing something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search id="base_search"&amp;gt;
    &amp;lt;query&amp;gt;
     index=...
     ``` Apply resource heavy filtering here, which should only be executed on page load ```
    &amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;search base="base_search" id="filtered_search"&amp;gt;
    &amp;lt;query&amp;gt;
     ``` Apply dashboard token filtering here ```
     | where name IN ($field1$)
    &amp;lt;/query&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;event&amp;gt;
        &amp;lt;search base="filtered_search"&amp;gt;
          &amp;lt;query&amp;gt;
            ``` Apply panel transforms here, repeat in multiple panels ```
            ...
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/event&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 17:38:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dropdown-quot-all-quot-from-dynamic-search-results/m-p/641462#M52382</guid>
      <dc:creator>rut</dc:creator>
      <dc:date>2023-04-26T17:38:12Z</dc:date>
    </item>
  </channel>
</rss>

