<?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: dynamic option in an input panel in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/dynamic-option-in-an-input-panel/m-p/343665#M5363</link>
    <description>&lt;P&gt;Don't forget to click &lt;CODE&gt;Accept&lt;/CODE&gt;.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2017 15:35:49 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-03-10T15:35:49Z</dc:date>
    <item>
      <title>dynamic option in an input panel</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/dynamic-option-in-an-input-panel/m-p/343661#M5359</link>
      <description>&lt;P&gt;HI all,&lt;BR /&gt;
I would to build a dynamic value for a dynamic option in an 'dropdown' panel for a dashboard (splunk 6.5.2)&lt;/P&gt;

&lt;P&gt;For example my query returns x results in a table : Number1, Number2, Number3 (to give an example with 3 values, but the result is always unknown). It allows to select between these 3 values to build a chart with a query like "index=blabla | timechart $myToken$ by myType". If Number1 is selected, the chart's query is "index=blabla | timechart SUM(Number1) by myType" because I need to draw the SUM.&lt;BR /&gt;
So my dynamic options have a token prefix "SUM(", and a token prefix ")".&lt;/P&gt;

&lt;P&gt;My need is to add a x+1 th (here a 4th) dynamic option "All", so that the resulted query for my chart is "index=blabla | timechart SUM(Number1), SUM(Number2), SUM(Number3) by myType".&lt;/P&gt;

&lt;P&gt;How can I do that ?&lt;BR /&gt;
Thank you,&lt;BR /&gt;
Arnaud&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 09:13:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/dynamic-option-in-an-input-panel/m-p/343661#M5359</guid>
      <dc:creator>Arnaud1213</dc:creator>
      <dc:date>2017-03-09T09:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic option in an input panel</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/dynamic-option-in-an-input-panel/m-p/343662#M5360</link>
      <description>&lt;P&gt;You need to do this in your &lt;CODE&gt;populatingsearch&lt;/CODE&gt;.  You can completely control what is returned from this search so you can put the &lt;CODE&gt;All&lt;/CODE&gt; value in &lt;EM&gt;yourself&lt;/EM&gt; using SPL.  Your &lt;CODE&gt;XML&lt;/CODE&gt; will have a line like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;populatingSearch fieldForValue="MyValue" fieldForLabel="MyLabel"&amp;gt;
    &amp;lt;![CDATA[index=_* OR index=* | dedup host | table host | rename host AS MyField | eventstats values(MyField) AS MyValue | reverse | appendpipe [|noop|stats count AS MyField|eval MyField="ALL(*)"] | nomv MyValue | rex field=MyValue mode=sed "s/^/SUM(/ s/ /) SUM(/ s/$/)/" | filldown MyValue | reverse | eval MyValue=if(like(MyField, "ALL(*)"), MyValue, "SUM(" . MyField . ")")]]&amp;gt;
&amp;lt;/populatingSearch&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Run the search by itself and see what it does.  You will need to change &lt;CODE&gt;host&lt;/CODE&gt; to your field but the gist is that we are controlling EVERYTHING in the replacement string creation and we have manually created the &lt;CODE&gt;ALL(*)&lt;/CODE&gt; value which includes the &lt;CODE&gt;SUM&lt;/CODE&gt; strings, too.&lt;/P&gt;

&lt;P&gt;Your dashboard panel search will now be this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blabla | timechart $new_token$ BY myType
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 16:16:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/dynamic-option-in-an-input-panel/m-p/343662#M5360</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-09T16:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic option in an input panel</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/dynamic-option-in-an-input-panel/m-p/343663#M5361</link>
      <description>&lt;P&gt;Take a look at this run-anywhere sample -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval mydata="Number1 Number2 Number3" 
| makemv mydata | mvexpand mydata | rename mydata as search 
| format "" "sum(" 2 ")" "" ""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...resulting in &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sum( Number1 ) sum( Number2 ) sum( Number3 )
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 16:35:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/dynamic-option-in-an-input-panel/m-p/343663#M5361</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-09T16:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic option in an input panel</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/dynamic-option-in-an-input-panel/m-p/343664#M5362</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Thank you for your answers.&lt;BR /&gt;
@Woodcock, I tried your proposition and it works, thank you.&lt;BR /&gt;
Unfortunately, it takes a long time to get the result. It's not because of your proposition, but because of my query.&lt;BR /&gt;
So I replaced your initial search by mine " ... | fieldsummary | search field=nb* | dedup field | sort field | table field rename field AS MyField | ...". And it takes a long time because of 'fieldsummary' searching.&lt;BR /&gt;
Thank you,&lt;BR /&gt;
Arnaud&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 08:57:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/dynamic-option-in-an-input-panel/m-p/343664#M5362</guid>
      <dc:creator>Arnaud1213</dc:creator>
      <dc:date>2017-03-10T08:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic option in an input panel</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/dynamic-option-in-an-input-panel/m-p/343665#M5363</link>
      <description>&lt;P&gt;Don't forget to click &lt;CODE&gt;Accept&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 15:35:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/dynamic-option-in-an-input-panel/m-p/343665#M5363</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-10T15:35:49Z</dc:date>
    </item>
  </channel>
</rss>

