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!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...