<?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 Custom Visualizations app: How to pass parameters from input forms to a search inside a div tag of an HTML panel? in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Custom-Visualizations-app-How-to-pass-parameters-from-input/m-p/270399#M31352</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;How can one pass input parameters from drop-down/textfield/etc  into a search that is inside a div tag of an html panel (I'm using bubble chart example)? &lt;BR /&gt;
$$mytoken$$ or $mytoken$ - doesn't work&lt;BR /&gt;
placing  &lt;CODE&gt;depends="$mytoken$"&lt;/CODE&gt; in html or div tag didn't help either&lt;/P&gt;

&lt;P&gt;Here's part of bubble chart example xml and we can see text inputs &lt;CODE&gt;term&lt;/CODE&gt; and &lt;CODE&gt;category&lt;/CODE&gt;, but they aren't displayed on a dashboard and aren't used in the search inside html. Is it possible at all? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="custom_vizs:autodiscover.js, custom_vizs:viz_bubblechart.js"&amp;gt;
  &amp;lt;label&amp;gt;Bubble Chart&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false" autoRun="true"&amp;gt;
    &amp;lt;input type="time" searchWhenChanged="true"&amp;gt;
      &amp;lt;default&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;/default&amp;gt;
    &amp;lt;/input&amp;gt;
    &amp;lt;input type="text" token="term" id="input_term"/&amp;gt;
    &amp;lt;input type="text" token="category" id="input_category"/&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;h2&amp;gt;Top 30 Most Common Terms in an Ad-hoc Search Query (drilldown)&amp;lt;/h2&amp;gt;
        &amp;lt;div id="bubblechart_search" class="splunk-manager" data-require="splunkjs/mvc/searchmanager" data-options='{
          "preview": true,
          "search": "index=_audit NOT REST: search=* | regex search_id=\"&amp;amp;apos;\\d+\\.\\d+&amp;amp;apos;\" | rex field=search max_match=0 \"(?&amp;lt;terms&amp;gt;\\w+)\" | eval terms=mvdedup(terms) | top limit=30 terms | lookup search_commands.csv search_command AS terms OUTPUT search_command | eval type=case(isnum(terms), \"number\", isnotnull(search_command), \"command\", 1=1, \"word\") | eval terms=if(isnum(terms), \"\\\"\"+terms+\"\\\"\", terms)",
          "earliest_time": {
            "type": "token_safe",
            "value": "$$earliest$$"
            },
          "latest_time": {
            "type": "token_safe",
            "value": "$$latest$$"
          }
        }'&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div id="bubblechart" class="splunk-view" data-require="app/custom_vizs/components/bubblechart/bubblechart" data-options='{
          "managerid": "bubblechart_search",
          "nameField": "terms",
          "valueField": "count",
          "categoryField": "type",
          "height": 600
        }'&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 30 Mar 2016 18:47:25 GMT</pubDate>
    <dc:creator>iKate</dc:creator>
    <dc:date>2016-03-30T18:47:25Z</dc:date>
    <item>
      <title>Custom Visualizations app: How to pass parameters from input forms to a search inside a div tag of an HTML panel?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Custom-Visualizations-app-How-to-pass-parameters-from-input/m-p/270399#M31352</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;How can one pass input parameters from drop-down/textfield/etc  into a search that is inside a div tag of an html panel (I'm using bubble chart example)? &lt;BR /&gt;
$$mytoken$$ or $mytoken$ - doesn't work&lt;BR /&gt;
placing  &lt;CODE&gt;depends="$mytoken$"&lt;/CODE&gt; in html or div tag didn't help either&lt;/P&gt;

&lt;P&gt;Here's part of bubble chart example xml and we can see text inputs &lt;CODE&gt;term&lt;/CODE&gt; and &lt;CODE&gt;category&lt;/CODE&gt;, but they aren't displayed on a dashboard and aren't used in the search inside html. Is it possible at all? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="custom_vizs:autodiscover.js, custom_vizs:viz_bubblechart.js"&amp;gt;
  &amp;lt;label&amp;gt;Bubble Chart&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false" autoRun="true"&amp;gt;
    &amp;lt;input type="time" searchWhenChanged="true"&amp;gt;
      &amp;lt;default&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;/default&amp;gt;
    &amp;lt;/input&amp;gt;
    &amp;lt;input type="text" token="term" id="input_term"/&amp;gt;
    &amp;lt;input type="text" token="category" id="input_category"/&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;h2&amp;gt;Top 30 Most Common Terms in an Ad-hoc Search Query (drilldown)&amp;lt;/h2&amp;gt;
        &amp;lt;div id="bubblechart_search" class="splunk-manager" data-require="splunkjs/mvc/searchmanager" data-options='{
          "preview": true,
          "search": "index=_audit NOT REST: search=* | regex search_id=\"&amp;amp;apos;\\d+\\.\\d+&amp;amp;apos;\" | rex field=search max_match=0 \"(?&amp;lt;terms&amp;gt;\\w+)\" | eval terms=mvdedup(terms) | top limit=30 terms | lookup search_commands.csv search_command AS terms OUTPUT search_command | eval type=case(isnum(terms), \"number\", isnotnull(search_command), \"command\", 1=1, \"word\") | eval terms=if(isnum(terms), \"\\\"\"+terms+\"\\\"\", terms)",
          "earliest_time": {
            "type": "token_safe",
            "value": "$$earliest$$"
            },
          "latest_time": {
            "type": "token_safe",
            "value": "$$latest$$"
          }
        }'&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div id="bubblechart" class="splunk-view" data-require="app/custom_vizs/components/bubblechart/bubblechart" data-options='{
          "managerid": "bubblechart_search",
          "nameField": "terms",
          "valueField": "count",
          "categoryField": "type",
          "height": 600
        }'&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Mar 2016 18:47:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Custom-Visualizations-app-How-to-pass-parameters-from-input/m-p/270399#M31352</guid>
      <dc:creator>iKate</dc:creator>
      <dc:date>2016-03-30T18:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Visualizations app: How to pass parameters from input forms to a search inside a div tag of an HTML panel?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Custom-Visualizations-app-How-to-pass-parameters-from-input/m-p/270400#M31353</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;"search": {
  "type": "token_safe",
  "value": "index=foo sourcetype=$$sourcetype$$ | stats count"
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The answer is in the Tutorial page of the Custom Visualization app:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Use the "token_safe" and the double-dollar sign syntax ($$token$$) to use tokens inside "data-options".
This also applies to the search query.
This is because if a regular $token$ is used then the &amp;lt;html&amp;gt; panel will clear everything in it if that $token$'s value changes.
"earliest_time": { 
  "type": "token_safe", 
  "value": "$$earliest$$" 
}, 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Mar 2016 19:55:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Custom-Visualizations-app-How-to-pass-parameters-from-input/m-p/270400#M31353</guid>
      <dc:creator>skawasaki_splun</dc:creator>
      <dc:date>2016-03-30T19:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Visualizations app: How to pass parameters from input forms to a search inside a div tag of an HTML panel?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Custom-Visualizations-app-How-to-pass-parameters-from-input/m-p/270401#M31354</link>
      <description>&lt;P&gt;Thanks! &lt;BR /&gt;
To be honest, I couldn't suppose to put all search string into value section even after reading tutorial.&lt;BR /&gt;
This is how my working dashboard(part) looks like now:   &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;fieldset submitButton="false" autoRun="true"&amp;gt;
    &amp;lt;input type="time" searchWhenChanged="true"&amp;gt;
      &amp;lt;default&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;/default&amp;gt;
    &amp;lt;/input&amp;gt;
    &amp;lt;input type="dropdown" token="devicemanufacturer"&amp;gt;
      &amp;lt;label&amp;gt;device manufacturer&amp;lt;/label&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;index=myindex earliest=-2d | stats dc(devicemanufacturer) as d by devicemanufacturer&amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;devicemanufacturer&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;devicemanufacturer&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;prefix&amp;gt;devicemanufacturer=&amp;lt;/prefix&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html &amp;gt;
            &amp;lt;h2&amp;gt;Top 30 Search Strings&amp;lt;/h2&amp;gt;
         &amp;lt;div id="search_words" class="splunk-manager" data-require="splunkjs/mvc/searchmanager" data-options="{
        "preview": true,
        "search": {
        "type": "token_safe",
        "value": " index=myindex $$devicemanufacturer$$ earliest=$$earliest$$ latest=$$latest$$| top limit=30 searchstr "
        }
        }"&amp;gt;
        &amp;lt;/div&amp;gt;
....
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Apr 2016 09:55:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Custom-Visualizations-app-How-to-pass-parameters-from-input/m-p/270401#M31354</guid>
      <dc:creator>iKate</dc:creator>
      <dc:date>2016-04-04T09:55:45Z</dc:date>
    </item>
  </channel>
</rss>

