Dashboards & Visualizations

How to get Splunk Web to parse JavaScipt to implement a countdown timer?

reach2tushar
Explorer

Hi Splunk –

We are trying to implement a countdown timer and seems script tags are not parsed by Splunk Web. The web simply ignores the Jquery/script tags. Can help with this or any alternate solution to get the countdown timer in on Splunk Web pages working?

0 Karma

gwobben
Communicator

You have to add your script from a separate file:

Add your script to an app:

$SPLUNK_HOME/etc/apps/<your_app>/appserver/static/<your_script>.js

And restart Splunk (otherwise new files won't be seen):

$SPLUNK_HOME/bin/splunk restart

Now go to your dashboard and add the script to the starting tag of the dashboard (could be <dashboard> or <form>😞

<dashboard script="<your_app>:<your_script>.js">

And save your dashboard. Now make sure your script looks something like this:

require([
    "jquery",
    "splunkjs/mvc/simplexml/ready!"
], function(
    $
) {

// Your script here

});

Good luck!

0 Karma

rjthibod
Champion

Can you clarify how you are trying to load the JS files?

Are you trying to load them in a Simple XML dashboard or a custom HTML dashboard?

0 Karma

reach2tushar
Explorer

Thanks for the reply.
We are adding following script in simple XML dashboard.

jQuery Countdown Basics

0 Karma

ppablo
Retired

Hi @reach2tushar

When sharing any sample code, please be sure to highlight the entire block of code and click on the "Code Sample" button in the text editing tools to ensure special characters render properly. This is why your sample JavaScript isn't shown.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...