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!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...