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!

Stay Connected: Your Guide to July Tech Talks, Office Hours, and Webinars!

What are Community Office Hours?Community Office Hours is an interactive 60-minute Zoom series where ...

Updated Data Type Articles, Anniversary Celebrations, and More on Splunk Lantern

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

A Prelude to .conf25: Your Guide to Splunk University

Heading to Boston this September for .conf25? Get a jumpstart by arriving a few days early for Splunk ...