<?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 create dynamic commands in search? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301419#M19233</link>
    <description>&lt;P&gt;Problem is that I use $radio$ other places in my config, and it's value can not be changed.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Apr 2017 05:28:06 GMT</pubDate>
    <dc:creator>lakromani</dc:creator>
    <dc:date>2017-04-04T05:28:06Z</dc:date>
    <item>
      <title>How to create dynamic commands in search?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301415#M19229</link>
      <description>&lt;P&gt;I would like to change the commands within a dashboard.&lt;/P&gt;

&lt;P&gt;I have a dropdown box like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="radio" token="radio" searchWhenChanged="true"&amp;gt;
  &amp;lt;label&amp;gt;Radio&amp;lt;/label&amp;gt;
  &amp;lt;choice value="*"&amp;gt;All&amp;lt;/choice&amp;gt;
  &amp;lt;choice value="Dot11Radio0"&amp;gt;2.4 GHz&amp;lt;/choice&amp;gt;
  &amp;lt;choice value="Dot11Radio1"&amp;gt;5.0 Ghz&amp;lt;/choice&amp;gt;
  &amp;lt;default&amp;gt;*&amp;lt;/default&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I would like the &lt;CODE&gt;timechart&lt;/CODE&gt; to reflect whats selected in dropdown box.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt;source="snmp://Cisco-Wifi-clients"
            | eval info=case(
                radio=="Dot11Radio0"
                    ,"avg(low) AS 2.4GHz"
                ,radio=="Dot11Radio1"
                    ,"avg(high) AS 5.0Ghz"
                ,1==1,"avg(high) AS 5.0Ghz avg(low) AS 2.4GHz")
            | timechart $info$&amp;lt;/query&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this does not work.&lt;BR /&gt;&lt;BR /&gt;
Anyone have another way to get this to work?&lt;/P&gt;

&lt;P&gt;Here is the base idea:&lt;BR /&gt;
This work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal user=* | timechart count by user limit=10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This does not.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal user=* | eval test="count by user limit=10" | timechart $test$
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2017 20:31:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301415#M19229</guid>
      <dc:creator>lakromani</dc:creator>
      <dc:date>2017-04-03T20:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dynamic commands in search?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301416#M19230</link>
      <description>&lt;P&gt;Hi lakromani.&lt;/P&gt;

&lt;P&gt;You probably need this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal user=* | timechart count by user limit=10 | search radio= \"$radio$\" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2017 20:47:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301416#M19230</guid>
      <dc:creator>rcarinha</dc:creator>
      <dc:date>2017-04-03T20:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dynamic commands in search?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301417#M19231</link>
      <description>&lt;P&gt;@lakromani... Shift the logic of your dynamic timechart aggregation from search to your input radio selection's change event. Try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="radio" token="radio" searchWhenChanged="true"&amp;gt;
  &amp;lt;label&amp;gt;Radio&amp;lt;/label&amp;gt;
  &amp;lt;choice value="*"&amp;gt;All&amp;lt;/choice&amp;gt;
  &amp;lt;choice value="Dot11Radio0"&amp;gt;2.4 GHz&amp;lt;/choice&amp;gt;
  &amp;lt;choice value="Dot11Radio1"&amp;gt;5.0 Ghz&amp;lt;/choice&amp;gt;
  &amp;lt;default&amp;gt;*&amp;lt;/default&amp;gt;
  &amp;lt;change&amp;gt;
    &amp;lt;condition value="Dot11Radio0"&amp;gt;
      &amp;lt;set token="aggrQuery"&amp;gt;avg(low) AS 2.4GHz&amp;lt;/set&amp;gt;
    &amp;lt;/condition&amp;gt;
    &amp;lt;condition value="Dot11Radio1"&amp;gt;
      &amp;lt;set token="aggrQuery"&amp;gt;avg(high) AS 5.0Ghz&amp;lt;/set&amp;gt;
    &amp;lt;/condition&amp;gt;
    &amp;lt;condition&amp;gt;
      &amp;lt;set token="aggrQuery"&amp;gt;avg(high) AS 5.0Ghz avg(low) AS 2.4GHz&amp;lt;/set&amp;gt;
    &amp;lt;/condition&amp;gt;
  &amp;lt;/change&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Use &lt;STRONG&gt;$aggrQuery$&lt;/STRONG&gt; token later in your search next to timechart.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:02:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301417#M19231</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-03T21:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dynamic commands in search?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301418#M19232</link>
      <description>&lt;P&gt;What if you just made the choice value be what you eval to in your query and pass that as a token?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="radio" token="radio" searchWhenChanged="true"&amp;gt;
   &amp;lt;label&amp;gt;Radio&amp;lt;/label&amp;gt;
   &amp;lt;choice value="*"&amp;gt;All&amp;lt;/choice&amp;gt;
   &amp;lt;choice value="avg(low) AS 2.4GHz"&amp;gt;2.4 GHz&amp;lt;/choice&amp;gt;
   &amp;lt;choice value="avg(high) AS 5.0Ghz"&amp;gt;5.0 Ghz&amp;lt;/choice&amp;gt;
   &amp;lt;default&amp;gt;*&amp;lt;/default&amp;gt;
 &amp;lt;/input&amp;gt;

&amp;lt;query&amp;gt;source="snmp://Cisco-Wifi-clients"
             | timechart $radio$&amp;lt;/query&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:44:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301418#M19232</guid>
      <dc:creator>briancronrath</dc:creator>
      <dc:date>2017-04-03T21:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dynamic commands in search?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301419#M19233</link>
      <description>&lt;P&gt;Problem is that I use $radio$ other places in my config, and it's value can not be changed.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 05:28:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301419#M19233</guid>
      <dc:creator>lakromani</dc:creator>
      <dc:date>2017-04-04T05:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dynamic commands in search?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301420#M19234</link>
      <description>&lt;P&gt;Perfect.  This did what I was looking for.  Since the &lt;STRONG&gt;$radio$&lt;/STRONG&gt; was used elsewhere in the script I could not change it.&lt;/P&gt;

&lt;P&gt;But I still do not understand why I can not set the &lt;STRONG&gt;$aggrQuery$&lt;/STRONG&gt; within the panel section of the Dashboard.  This could be added by the Splunk guys &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 05:45:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301420#M19234</guid>
      <dc:creator>lakromani</dc:creator>
      <dc:date>2017-04-04T05:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to create dynamic commands in search?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301421#M19235</link>
      <description>&lt;P&gt;Splunk has a map command where you can recursively execute SPL for selected field. (&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Map"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Map&lt;/A&gt;). I have used makeresults but you can use timechart instead.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;fieldset&amp;gt;
   &amp;lt;input type="radio" token="radio" searchWhenChanged="true"&amp;gt;
   &amp;lt;label&amp;gt;Radio&amp;lt;/label&amp;gt;
   &amp;lt;choice value="*"&amp;gt;All&amp;lt;/choice&amp;gt;
   &amp;lt;choice value="Dot11Radio0"&amp;gt;2.4 GHz&amp;lt;/choice&amp;gt;
   &amp;lt;choice value="Dot11Radio1"&amp;gt;5.0 Ghz&amp;lt;/choice&amp;gt;
   &amp;lt;default&amp;gt;*&amp;lt;/default&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;query&amp;gt;| makeresults
| eval aggrQuery=case("$radio$"=="Dot11Radio0","avg(low) AS 2.4GHz","$radio$"=="Dot11Radio1","avg(high) AS 5.0Ghz",true(),"avg(high) AS 5.0Ghz avg(low) AS 2.4GHz")
| map search="| makeresults | eval UseMappedresult=\"$aggrQuery$\""&amp;lt;/query&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Apr 2017 06:10:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-commands-in-search/m-p/301421#M19235</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-04T06:10:42Z</dc:date>
    </item>
  </channel>
</rss>

