Dashboards & Visualizations

Adding a CSS and JavaScript source to an app's HTML Dashboard

Jonathan_hyde
Explorer

Hello all,

I've looked around and have tried some other answers but are unable to have it functioning correctly.

We're looking to add CSS and JavaScript to an app, however when we load our instance we are unable to load the source up, we've made sure the directory is correct, we've used the regular HTML expressions:

LukeMurphey
Champion

Put the content in application.css and application.js accordingly. The paths are as follows:

  • $SPLUNK_HOME/etc/apps//appserver/static/application.js
  • $SPLUNK_HOME/etc/apps//appserver/static/application.css

These files will be loaded for every page within your app context.

You can put other resources (such as images) in the appserver/static directory too. Then, refer to them in the CSS using a relative path.

Here is an example:
Assume that an image named "picture.png" was placed in the following directory:

$SPLUNK_HOME/etc/apps//appserver/static/images/picture.png

You could reference this in your stylesheet like this:

.somePicture {
    background-image: url('images/picture.png');
}

LukeMurphey
Champion

Just added info to the answer regarding how to link to images in your stylesheet.

0 Karma

Jonathan_hyde
Explorer

Brilliant it worked thanks, final question - do you know how to add images, as the css links to the images too? Thanks.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...