Dashboards & Visualizations

Button to run Splunk query | outputlookup

michael_vi
Path Finder

Hi,

Sorry for repeating questions, that were already answered in... 

https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/576236#M472...


I'm trying to make a simple outputlookup with user's confirmation window and I'm struggling with the following issues:

1. Every time I refresh the page the query executes by itself but when I press the submit button, nothing happens.

2. How can I make a comment or popup or display some message after clicking the submit button: "Thank you for clicking" + writing a click time.

This is what I have for now

<form script="test_submit.js">
   <row>
      <panel id="test">
         <table>
            <search id="base">
               <query>index=_internal 
| head 10000
| bin _time span=12h 
| stats count by sourcetype source name _time</query>
               <sampleRatio>1</sampleRatio>
            </search>
            <option name="count">6</option>
            <option name="dataOverlayMode">none</option>
            <option name="drilldown">none</option>
            <option name="percentagesRow">false</option>
            <option name="rowNumbers">false</option>
            <option name="totalsRow">false</option>
            <option name="wrap">true</option>
         </table>
      </panel>
   </row>
   <row>
      <panel>
         <html>
            <div>
               <button type="button" id="buttonId" class="btn btn-primary">Submit</button>
            </div>
         </html>
      </panel>
   </row>
   <row>
      <panel>
         <search base="base">
            <query>| eval time = now() | outputlookup append=t users.csv</query>
         </search>
      </panel>
   </row>
</form>

 

JS

 

require([
        'jquery',
        'splunkjs/mvc',
        'splunkjs/mvc/simplexml/ready!'
    ], function ($, mvc) {
    function submit_btn() {
                var submittedTokens = mvc.Components.get('submitted');
                var defaultTokens = mvc.Components.get('default');
                if (submittedTokens && defaultTokens) {
                        submittedTokens.set(defaultTokens.toJSON());
        	       }
            }
    $('#buttonId').on("click", function (){
        submit_btn();
    });
   });
 

 

Thanks a lot

Labels (1)
0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco &#43; Splunk! We’ve ...