Dashboards & Visualizations

change background color of a single value result according to the text in simple xml

smolcj
Builder

Hi,
i have a single value module which returns either a yes or a no, how to change their color to green if the result is NO and red if it is YES. i am working in simple xml. i tried changing the application.css with
..singleResult .YES{
color: #FF0000;
}
plese help
Thank you

Tags (2)
0 Karma
1 Solution

jonuwz
Influencer

Lets say your search outputs a field called 'yes_or_no' that contains 'YES' or 'NO' (probably using rangemap)

Your dashboard would look like :

<?xml version='1.0' encoding='utf-8'?>
<dashboard>
  <label>Example</label>
  <row>
    <single>
      <searchTemplate>... | table yes_or_no</searchTemplate>
      <title>YES or NO</title>
      <option name="classField">yes_or_no</option>
    </single>
  </row>
</dashboard>

Its the classField parameter that determines what css class it'll pick up

And your application.css would look like :

.SingleValue .NO .singleResult {
    color: #ffb800;
}

.SingleValue .YES .singleResult {
    color: #ffb800;
}

You need to restart splunk if application.css has just been created for the 1st time.

View solution in original post

jonuwz
Influencer

Lets say your search outputs a field called 'yes_or_no' that contains 'YES' or 'NO' (probably using rangemap)

Your dashboard would look like :

<?xml version='1.0' encoding='utf-8'?>
<dashboard>
  <label>Example</label>
  <row>
    <single>
      <searchTemplate>... | table yes_or_no</searchTemplate>
      <title>YES or NO</title>
      <option name="classField">yes_or_no</option>
    </single>
  </row>
</dashboard>

Its the classField parameter that determines what css class it'll pick up

And your application.css would look like :

.SingleValue .NO .singleResult {
    color: #ffb800;
}

.SingleValue .YES .singleResult {
    color: #ffb800;
}

You need to restart splunk if application.css has just been created for the 1st time.

MuS
Legend

thanks for this, I was just wondering yesterday how to do this and now it is done. splunk-base - what great source!

0 Karma

smolcj
Builder

Thank youu

0 Karma

jonuwz
Influencer

In that case classField should be x.
class field is the field in the search that sets the class.

yes_or_no isn't a field in your search

smolcj
Builder

i am using a form with a dropdown box and my single value panel is like

  


index=main source=$sources$ |eval x=if(severity="FATAL","YES","NO") | sort - x |table x |head 1

FATAL :

yes_or_no

changed application.css with above code. still the single result is in black in color.

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...