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!

Enterprise Security Content Update (ESCU) | New Releases

In September, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...

New in Observability - Improvements to Custom Metrics SLOs, Log Observer Connect & ...

The latest enhancements to the Splunk observability portfolio deliver improved SLO management accuracy, better ...

Improve Data Pipelines Using Splunk Data Management

  Register Now   This Tech Talk will explore the pipeline management offerings Edge Processor and Ingest ...