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
SplunkTrust
SplunkTrust

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!

How to Monitor Google Kubernetes Engine (GKE)

We’ve looked at how to integrate Kubernetes environments with Splunk Observability Cloud, but what about ...

Index This | How can you make 45 using only 4?

October 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Splunk Education Goes to Washington | Splunk GovSummit 2024

If you’re in the Washington, D.C. area, this is your opportunity to take your career and Splunk skills to the ...