Dashboards & Visualizations

splunk6 custom HTML visualization not updating if form input changes

mathu
Path Finder

Hi

I've written a custom view in Splunk6 that shows me search results as plain HTML content.
The simple xml view works and shows my html content when the page loads. But if I try to use form inputs such as a dropdown, the view doesn't update when I hit the submit button.

I've basically copy/pasted the examples from Splunk6 custom visualization examples, the code looks as follows:

following code gives me a dropdown with a list of splunk apps:

<fieldset autoRun="true">
   <input type="dropdown" token="app_name" searchWhenChanged="false">
     <label>Select an App:</label>
       <populatingSearch fieldForValue="app" fieldForLabel="app">
         <![CDATA[ | script python splunksvn -v ]]>
       </populatingSearch>
   </input>
[...]
</fieldset>

following code integrates my custom visualization:

    [...]
    <html>
        <h2>local svn diff</h2>
        <div id="htmlcontent-diffsearch"
             class="splunk-manager splunk-searchmanager "
             data-require="splunkjs/mvc/searchmanager"
             data-options='{
                    "app": "subversion",
                    "preview": true,
                    "search": { "type": "token_safe", "value": "| script python splunksvn -c $app_name$}
                }'>
        </div>
        <div id="htmlcontent-diff"
             class="splunk-view"
             data-require="app/subversion/components/htmlcontent/htmlcontent"
             data-options='{
                    "managerid": "htmlcontent-diffsearch"
                 }'>
        </div>
    </html>
    [...]

In my htmlcontent.js file I've basically just implemented the "updateView" function:

    [...]
    updateView: function(viz, data) {
        var myResults = data[0];  // Sets this to the first (and only) row
        this.$el.html(myResults);
    }
    [...]

I suspect that the "html" element in simple xml doesn't know anything about the submit action. But how can I tell my view to update?

Kind regards
mathu

0 Karma
1 Solution

mathu
Path Finder

Using double dollar signs for the token in the search string helped...

changing:

"search": { "type": "token_safe", "value": "| script python splunksvn -c $app_name$ }

to:

"search": { "type": "token_safe", "value": "| script python splunksvn -c $$app_name$$ }

View solution in original post

ppohar
Explorer

Thanks, this worked for me.

0 Karma

mathu
Path Finder

Using double dollar signs for the token in the search string helped...

changing:

"search": { "type": "token_safe", "value": "| script python splunksvn -c $app_name$ }

to:

"search": { "type": "token_safe", "value": "| script python splunksvn -c $$app_name$$ }

dominiquevocat
Motivator

I do have the same issue (my impression) as the question asker and when i try this trick with the double $ then i will never ever get a result :-=)

0 Karma

yplambert
New Member

Are you aware that your "value": "| script... doesn't have a closing quotation mark? Could that be the problem, or is it just a copy/paste artifact?

0 Karma

MattZerfas
Communicator

This worked for me thanks!

0 Karma

mathu
Path Finder

.. by the way, the code works with all ohter elements (such as table, chart, single). "html" seems to be the only element not reacting on form changes

0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...