Dashboards & Visualizations

How to make form refresh value configurable?

simpkins1958
Contributor

We have a number of dashboards that have their form refresh attribute set to "300" for a 5 minute refresh rate. We want to make the 300 value configurable. Any suggestions?

<form refresh="300" >
...
...
</form>
0 Karma
1 Solution

niketnilay
Legend

@simpkins1958, one of the ways to do this could be through JavaScript. You can have your own JS file which sets dashboard refresh to specific value for example 5 minutes in this case: setTimeout("location.reload();", 300 * 1000);

Instead of using refresh="300" you can use script="dashboard_refresh.js" in all your dashboards/forms. In case you need to modify this interval you can do it at single place via this JavaScript file (you can create different script files/parameters within script for handling multiple refresh intervals for your dashboard.

Simple Code for dashboard_refresh.js

require([
    'underscore',
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {
    // Set Dashboard Timeout
        setTimeout("location.reload();", 300 * 1000);
});
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

gokikrishnan198
New Member

I feel there is no contradiction. When there is a need demand comes and when demand comes we change the refresh rate of the dashboard.
I also gave an example in the previous answer which is chrome extension, “Easy Auto-Refresh”. I request you to have a look at it if you don’t mind.
As Splunk is mainly used for monitoring, we from SOC team needs a real-time monitoring which is a very important factor. In that case, following are the reasons,
1) You cannot expect me to Press F5 Key all the times.

2) I can think of another option which is updating the Form of the dashboard.
3) Also, I can go ahead with writing a JS Query as mentioned in the link given.
I accept these can be performed. But these are all work-around. Don’t Splunk have an option available in-built? Please suggest if available.

0 Karma

niketnilay
Legend

@gokikrishnan1982, I think you have posted on wrong answer. You should have posted a comment on your original question i.e. https://answers.splunk.com/answers/663030/how-to-auto-refresh-the-dashboard-using-splunk-app-3.html

After looking at a Easy Auto Refresh behavior, seems like you are looking for an option to have dashboard refreshed on a regular interval, which can be done via refresh attribute i.e. <form refresh="300"> or <dashboard refresh="300"> which sets refresh time to 300 seconds or 5 minute. Refer to documentation below:

http://docs.splunk.com/Documentation/Splunk/latest/Viz/PanelreferenceforSimplifiedXML#dashboard_or_f...

If you want this setting as configurable setting in the UI, you would need to code using JavaScript. Which is not a workaround as depending on coding level Simple XML JS Extension, HTML Dashboards and Splunk JS stack are all Splunk App Development mechanisms. Please let us know if you would need a help with this.

From UI Splunk gives you an option to set the Refresh Interval of individual Panels in the Dashboard by Refreshing <search> using <refresh> attribute. (If you establish a dependency between base search and all remaining searches, you can set this once and it will do a cascaded refresh or other searches as well). Refer to documentation: http://docs.splunk.com/Documentation/Splunk/latest/Viz/PanelreferenceforSimplifiedXML#search

If none of these cater to your needs and you need Splunk UI to support dashboard/form <refresh>, you would need to request an enhancement in Splunk by reaching out to Splunk Support with your Splunk Entitlement.

PS: I will post this same answer also on your original question as this is a different answer only for your reference.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

niketnilay
Legend

@simpkins1958, one of the ways to do this could be through JavaScript. You can have your own JS file which sets dashboard refresh to specific value for example 5 minutes in this case: setTimeout("location.reload();", 300 * 1000);

Instead of using refresh="300" you can use script="dashboard_refresh.js" in all your dashboards/forms. In case you need to modify this interval you can do it at single place via this JavaScript file (you can create different script files/parameters within script for handling multiple refresh intervals for your dashboard.

Simple Code for dashboard_refresh.js

require([
    'underscore',
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {
    // Set Dashboard Timeout
        setTimeout("location.reload();", 300 * 1000);
});
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

simpkins1958
Contributor

This works well. Thanks.

0 Karma

niketnilay
Legend

Glad it worked 🙂

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Register for .conf21 Now! Go Vegas or Go Virtual!

How will you .conf21? You decide! Go in-person in Las Vegas, 10/18-10/21, or go online with .conf21 Virtual, 10/19-10/20.