<?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: Button to run splunk query in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/454739#M29819</link>
    <description>&lt;P&gt;Setup your dashboard like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="run_action.js"&amp;gt;
  &amp;lt;label&amp;gt;Test Action&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;button class="btn btn-primary button1"&amp;gt;Run search!&amp;lt;/button&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the add run_action.js to &lt;CODE&gt;&amp;lt;app_folder&amp;gt;/appserver/static&lt;/CODE&gt; of the &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;         require([
            "jquery",
            "splunkjs/mvc/searchmanager",
            "splunkjs/mvc/simplexml/ready!"
          ], function(
              $,
              SearchManager
          ) {
              var mysearch = new SearchManager({
                  id: "mysearch",
                  autostart: "false",
                  search: "|makeresults| outputlookup myfile" 
              });
              $(".button1").on("click", function (){
                  var ok = confirm("Are you sure?");
                  if (ok){
                      mysearch.startSearch();
                      alert('attempted restart!');
                  } //else {
                  //    alert('user did not click ok!');
                  //}
              });
         });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The dashboard needs to be in the same splunk "app" as the javascript file.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 23:06:04 GMT</pubDate>
    <dc:creator>chrisyounger</dc:creator>
    <dc:date>2020-09-29T23:06:04Z</dc:date>
    <item>
      <title>Button to run splunk query</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/454738#M29818</link>
      <description>&lt;P&gt;Hello &lt;/P&gt;

&lt;P&gt;I'm pretty  new to the Dashboard creating in splunk, and to xml in general. &lt;/P&gt;

&lt;P&gt;I want to know if there is a way to create a button that will run a splunk search on a click. &lt;/P&gt;

&lt;P&gt;I'm trying to create a button that if is clicked, it will create a lookup file by the next search : &lt;BR /&gt;
&lt;PRE&gt;| inputlookup "template.csv" | outputlookup "newlookup"."csv" &lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;I know that there is an option to use java script through &lt;CODE&gt;onclick&lt;/CODE&gt; but the problem is that the query is in splunk syntax and i don't  think java script can parse it.  &lt;/P&gt;

&lt;P&gt;Also can i create this button to appear only if there is a value in other input ? &lt;/P&gt;

&lt;P&gt;Can anyone help? &lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 15:54:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/454738#M29818</guid>
      <dc:creator>astatrial</dc:creator>
      <dc:date>2019-02-06T15:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Button to run splunk query</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/454739#M29819</link>
      <description>&lt;P&gt;Setup your dashboard like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="run_action.js"&amp;gt;
  &amp;lt;label&amp;gt;Test Action&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;button class="btn btn-primary button1"&amp;gt;Run search!&amp;lt;/button&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the add run_action.js to &lt;CODE&gt;&amp;lt;app_folder&amp;gt;/appserver/static&lt;/CODE&gt; of the &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;         require([
            "jquery",
            "splunkjs/mvc/searchmanager",
            "splunkjs/mvc/simplexml/ready!"
          ], function(
              $,
              SearchManager
          ) {
              var mysearch = new SearchManager({
                  id: "mysearch",
                  autostart: "false",
                  search: "|makeresults| outputlookup myfile" 
              });
              $(".button1").on("click", function (){
                  var ok = confirm("Are you sure?");
                  if (ok){
                      mysearch.startSearch();
                      alert('attempted restart!');
                  } //else {
                  //    alert('user did not click ok!');
                  //}
              });
         });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The dashboard needs to be in the same splunk "app" as the javascript file.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:06:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/454739#M29819</guid>
      <dc:creator>chrisyounger</dc:creator>
      <dc:date>2020-09-29T23:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Button to run splunk query</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/454740#M29820</link>
      <description>&lt;P&gt;I did it but for some reason it doesn't work. &lt;BR /&gt;
Nothing happens when i press the button. &lt;/P&gt;

&lt;P&gt;Also is there a way to send a token (of one of the other inputs in the dashboard) to that java script ? &lt;/P&gt;

&lt;P&gt;Thank you very much!!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 08:49:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/454740#M29820</guid>
      <dc:creator>astatrial</dc:creator>
      <dc:date>2019-02-07T08:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Button to run splunk query</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/454741#M29821</link>
      <description>&lt;P&gt;I managed to get it work, based on your answer. &lt;BR /&gt;
Thanks ! &lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 13:34:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/454741#M29821</guid>
      <dc:creator>astatrial</dc:creator>
      <dc:date>2019-05-06T13:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Button to run splunk query</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/516617#M34572</link>
      <description>&lt;P&gt;I have also the same problem.. I want search particular parameter inside the host file with the selectable date drop down&lt;/P&gt;&lt;P&gt;Below source code only shows one field and also not giving any output.&lt;/P&gt;&lt;P&gt;++++++++++&lt;/P&gt;&lt;P&gt;&amp;lt;form&amp;gt;&lt;BR /&gt;&amp;lt;label&amp;gt;ODSEE Backend SEARCH&amp;lt;/label&amp;gt;&lt;BR /&gt;&amp;lt;fieldset autoRun="false" submitButton="true"&amp;gt;&lt;BR /&gt;&amp;lt;input type="text" token="twguid"&amp;gt;&lt;BR /&gt;&amp;lt;label&amp;gt;Search ID&amp;lt;/label&amp;gt;&lt;BR /&gt;&amp;lt;default&amp;gt;put your search here&amp;lt;/default&amp;gt;&lt;BR /&gt;&amp;lt;prefix&amp;gt;'twguid'="&amp;lt;/prefix&amp;gt;&lt;BR /&gt;&amp;lt;suffix&amp;gt;"&amp;lt;/suffix&amp;gt;&lt;BR /&gt;&amp;lt;/input&amp;gt;&lt;BR /&gt;&amp;lt;/fieldset&amp;gt;&lt;BR /&gt;&amp;lt;row&amp;gt;&lt;BR /&gt;&amp;lt;panel&amp;gt;&lt;BR /&gt;&amp;lt;table&amp;gt;&lt;BR /&gt;&amp;lt;search&amp;gt;&lt;BR /&gt;&amp;lt;query&amp;gt;&lt;BR /&gt;index=auth_odsee* host="*" conn=* twguid=*&lt;BR /&gt;| search $twguid$&lt;BR /&gt;| table '_date' 'twguid' 'host' &amp;lt;/query&amp;gt;&lt;BR /&gt;&amp;lt;earliest&amp;gt;-10m&amp;lt;/earliest&amp;gt;&lt;BR /&gt;&amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;&lt;BR /&gt;&amp;lt;/search&amp;gt;&lt;BR /&gt;&amp;lt;/table&amp;gt;&lt;BR /&gt;&amp;lt;/panel&amp;gt;&lt;BR /&gt;&amp;lt;/row&amp;gt;&lt;BR /&gt;&amp;lt;/form&amp;gt;&lt;/P&gt;&lt;P&gt;+++++++++++++++++++++&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 02:13:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/516617#M34572</guid>
      <dc:creator>rodrigrc</dc:creator>
      <dc:date>2020-08-28T02:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Button to run splunk query</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/565700#M46475</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have done below and replaced the SPL with the following.&lt;/P&gt;&lt;P&gt;BUt the .sh scripts run when I load the page the first time, how can I stop that from happening.&lt;/P&gt;&lt;P&gt;I would like it to work just when I press the button.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;P&gt;A simple&amp;nbsp;| runshellscript Test_Script123.sh 1 1 1 1 1 1 1 1 .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;require([
            "jquery",
            "splunkjs/mvc/searchmanager",
            "splunkjs/mvc/simplexml/ready!"
          ], function(
              $,
              SearchManager
          ) {
              var mysearch = new SearchManager({
                  id: "mysearch",
                  autostart: "false",
                  search: "| runshellscript Test_Script123.sh 1 1 1 1 1 1 1 1" 
              });
              $(".button1").on("click", function (){
                  var ok = confirm("Are you sure?");
                  if (ok){
                      mysearch.startSearch();
                      alert('attempted restart!');
                  } //else {
                  //    alert('user did not click ok!');
                  //}
              });
         });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 17:33:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/565700#M46475</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2021-09-02T17:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Button to run splunk query</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/576501#M47242</link>
      <description>&lt;P&gt;The dashboard executes when the page refreshes + when the button is pressed.&lt;/P&gt;&lt;P&gt;How to disable the "refresh" page?&lt;/P&gt;</description>
      <pubDate>Sun, 28 Nov 2021 05:07:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Button-to-run-splunk-query/m-p/576501#M47242</guid>
      <dc:creator>michael_vi</dc:creator>
      <dc:date>2021-11-28T05:07:59Z</dc:date>
    </item>
  </channel>
</rss>

