Who doesn’t love building “shiny” dashboards and getting the following reaction from their viewers? One trick to add some extra flare to your dashboards is replacing your single value rangemap icons with your own images that change color or to a different image depending on the value. This even includes animated .gif or svgs! For example the Operational Intelligence dashboard below shows one use case of single value icon replacements. In fact, the “Power” and “HVAC” icons on the bottom right are animated .gifs and both change color and spin faster according to the single value result. Cool eh? Let’s see how this is done so you can build your own! Note: This only works on 6.1.x and 6.2.x!
Additionally you can find another example of single value icon replacements using traffic lights here!
Alrighty then let’s get started!
Step 1:
If you don’t already have it, download and install the Splunk 6.x Dashboards app (I love this dang app!). We are going to use the Single Value Decorations example as a starting point. I tend to clone or copy the dashboard somewhere else so I don’t modify the original example. In this case I even built a separate app with the clone of the dashboard to keep things even simpler (completely optional).
Step 2:
You will notice the Single Value Decorations example requires a .css file called “single_decorations.css”. If you create a separate app, you will need to copy this file over to your appserver/static directory. Otherwise you can just modify the existing “single_decorations.css” directly in the Splunk 6.x Dashboards example app.
$SPLUNK_HOME/etc/apps/yourappname/appserver/static
The XML at the top of your cloned dashboard should now include this .css file. Additionally I cleaned up the xml to only show one row and just a few of the icon-only single values.
<dashboard stylesheet="single_decorations.css">
Your XML and dashboard should look like this:
Step 3:
Now that we a nice simple canvas to work with we can get to the real fun. First we need some images or icons. In this example we will pick an icon with 5 different colors (1 icon for each color in the rangemap). In my example I’m using icons called “customer_support” followed by the color. These icons should be placed in your $SPLUNK_HOME/etc/apps/yourappname/appserver/static directory.
That directory should now contain something similar to the following: a set of icons and your single_decorations.css file.
Step 4:
Next it’s time to modify the XML so that our single value icon can be referenced from the “single_decorations.css” file. All we need to do is add an “ID” to the single value as shown below. This will help us maintain the existing single decoration icon setup and only change the specific single values we want.
<single> to <single id=”customer_support”>
Step 5:
Now we need to modify the .css to accommodate for ID and the rangemap values.
Using the existing single_decorations.css we will add the following lines below. Notice how there is an entry for each color so you should have 5 sets of #customer_support references. The values Splunk is using from a rangemap perspective are “none,low,guarded,elevated,high,severe”. There are some extra lines in the .css that are mostly self-explanatory such as height and width of the icon. You can change these accordingly to best fit your dashboard customizations.
#customer_support .low.single-value:before { display:inherit; background: url('customer_support_green.svg'); background-size: 55px 55px !important; background-repeat: no-repeat; height:55px; width:55px; content:" " !important; } #customer_support .guarded.single-value:before { display:inherit; background: url('customer_support_lightblue.svg'); background-size: 55px 55px !important; background-repeat: no-repeat; height:55px; width:55px; height:55px; } #customer_support .low.single-value:before { display:inherit; background: url('customer_support_green.svg'); …
Step 6:
Time for a restart in order for Splunk to acknowledge our new dashboard and the referenced .css file. You should now see something like this:
And if you change your value in that panel’s search to 250 instead of 550, you should see:
If this doesn’t work double-check both your xml and .css 😉 and that you restarted your Search Head you are doing the work on.
Congratulations! You now have your own icons changing colors or image based on the single value! Now you can add other icon sets for the rest of the icons and build your own awesome dashboards!