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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...