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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...