Dashboards & Visualizations

How to allow dashboard users to turn off auto-refresh?

brajaram
Communicator

I have a dashboard that looks at the last 15 minutes, and refreshes every 2 minutes.

<form refresh="120> in the dashboard code.

However, I want a way for viewers of the dashboard to be able to turn off the refresh if they desire. How do I add an input to toggle the auto-refresh?

Tags (2)
1 Solution

paramagurukarth
Builder

In refresh option splunk is not doing any data only refresh. They are doing simple page refresh.
You can achieve that functionality by using simple javascript.

<!-- Custom Refresh>
<form script="custom_refresh.js">
  <label>Test_Refresh</label>
  <row>
    <panel>
      <html>
        <input id="is_refresh_enabled" type="checkbox" checked="">Refresh</input>
      </html>
    </panel>
  </row>
  <row>
    <panel>
      <event>
        <search>
          <query>index="_internal" | head 10</query>
        </search>
        <option name="count">20</option>
        <option name="list.drilldown">none</option>
        <option name="list.wrap">1</option>
        <option name="maxLines">5</option>
        <option name="raw.drilldown">full</option>
        <option name="rowNumbers">0</option>
        <option name="table.drilldown">all</option>
        <option name="table.sortDirection">asc</option>
        <option name="table.wrap">1</option>
        <option name="type">list</option>
      </event>
    </panel>
  </row>
</form>

.

//custom_refresh.js
// Place this file inside /appserver/static/ folder of your application
require([
    "jquery",
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
    ], function($, mvc){
    console.log("Test");
    setInterval(function(){
        if(document.getElementById("is_refresh_enabled").checked){
            window.location.reload();
        }         
    }, 10000);
});

Refer Javascript related tweaks here

View solution in original post

paramagurukarth
Builder

In refresh option splunk is not doing any data only refresh. They are doing simple page refresh.
You can achieve that functionality by using simple javascript.

<!-- Custom Refresh>
<form script="custom_refresh.js">
  <label>Test_Refresh</label>
  <row>
    <panel>
      <html>
        <input id="is_refresh_enabled" type="checkbox" checked="">Refresh</input>
      </html>
    </panel>
  </row>
  <row>
    <panel>
      <event>
        <search>
          <query>index="_internal" | head 10</query>
        </search>
        <option name="count">20</option>
        <option name="list.drilldown">none</option>
        <option name="list.wrap">1</option>
        <option name="maxLines">5</option>
        <option name="raw.drilldown">full</option>
        <option name="rowNumbers">0</option>
        <option name="table.drilldown">all</option>
        <option name="table.sortDirection">asc</option>
        <option name="table.wrap">1</option>
        <option name="type">list</option>
      </event>
    </panel>
  </row>
</form>

.

//custom_refresh.js
// Place this file inside /appserver/static/ folder of your application
require([
    "jquery",
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
    ], function($, mvc){
    console.log("Test");
    setInterval(function(){
        if(document.getElementById("is_refresh_enabled").checked){
            window.location.reload();
        }         
    }, 10000);
});

Refer Javascript related tweaks here

nicolocervo
Engager

worked for me 👍

varun8159
Explorer

You would need some bit of Javascript code.

0 Karma

brajaram
Communicator

Any idea as to where I should begin to do that?

0 Karma

ddrillic
Ultra Champion

@brajaram, please keep in mind that this auto-refresh can apply a heavy load on the environment.

We spoke a bit about it at - Does a dashboard keep refreshing itself by default?

    <form refresh="0"> 

is my favorite.

0 Karma
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...