Dashboards & Visualizations

How to embed JavaScript and CSS within the dashboard or panel?

garinapavan
Explorer

Hi,

I have a dashboard which with javascript and custom style sheet and I have them in $SPLUNK_HOME/etc/apps//appserver/static/

But I want to have that code within the below dashboard code and at the panel level instead of putting the files in /appserver/static/ folder. Can you provide some examples how to put the javascript code and style sheet code within my panel?

Below is my Dashboard code :

<dashboard script="table_cell_highlighting.js" stylesheet="table_cell_highlighting.css">
  <label>cellcoloring</label>
  <row>
    <panel>
      <table id="highlight">
        <search>
          <query>host=abc  source="access.log*"  |stats  perc90(duration) as Duration,perc95(duration) as ninetyfifth by   service_name | sort -count</query>
          <earliest>-60m@m</earliest>
          <latest>now</latest>
        </search>
      </table>
    </panel>
  </row>
</dashboard>

Any help is appreciated !

rjthibod
Champion

You can put CSS inline in an html element under a row element like this

<row depends="hiddenCSS">
  <html>
    <style> 
      /*insert CSS here, can only reference classes and IDs, no selectors */
    </style>
  </html>
</row>

You CANNOT embed Javascript inside of a SimpleXML dashboard. It can only be loaded from files like you are doing.

0 Karma
Get Updates on the Splunk Community!

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

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

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