Dashboards & Visualizations

Unable to color text in single value field

Bleepie
Communicator

Dear Splunk Community,

I have the following code:

<dashboard>
  <label></label>
  <row>
    <panel>
      <single>
        <search>
          <query>host="DESKTOP-L4ID3T2" 
source="BatchProcessor*" 
inventoryimport* 
"ExitCode: 0" 
| stats count
| eval msg=case(count == 0, "Scan niet succesvol!", count &gt; 0, "Scan succesvol!")
| eval range=case(count == 0, "severe", count &gt; 0, "low")
| table msg</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="field">range</option>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </single>
    </panel>
  </row>
</dashboard>

 

If count returns 0 events, I expect the color of the single value field to be red (severe), otherwise it should be green (low). But using the above code, there is no color at all (besides the default color black and white). 

Why is the above not working?

Thanks in advance.

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Go back to

| table msg range

and remove this line

        <option name="field">range</option>

 

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try adding these options

<option name="colorBy">value</option>
<option name="rangeColors">["0x53a051","0xdc4e41"]</option>
0 Karma

Bleepie
Communicator

Unfortunately it doesn't apply:

splunk.PNG

Code:

<dashboard>
  <label></label>
  <row>
    <panel>
      <single>
        <search>
          <query>host="DESKTOP-L4ID3T2" 
source="BatchProcessor*" 
inventoryimport* 
"ExitCode: 0" 
| stats count
| eval msg=case(count == 0, "Scan niet succesvol!", count &gt; 0, "Scan succesvol!")
| eval range=case(count == 0, "severe", count &gt; 0, "low")
| table msg</query>
          <earliest>0</earliest>
          <latest></latest>
        </search>
        <option name="field">range</option>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>
        <option name="colorBy">value</option>
        <option name="rangeColors">["0x53a051","0xdc4e41"]</option>
      </single>
    </panel>
  </row>
  <row>
    <panel>
      <single>
        <search>
          <query>host="DESKTOP-L4ID3T2" 
source="BatchProcessor*" 
inventoryimport* 
"ExitCode: 0" 
| stats count
| eval msg=case(count == 0, "Scan niet succesvol!", count &gt; 0, "Scan succesvol!")
| eval range=case(count == 0, "severe", count &gt; 0, "low")
| table msg</query>
          <earliest>@d</earliest>
          <latest>now</latest>
        </search>
        <option name="field">range</option>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>
        <option name="colorBy">value</option>
        <option name="rangeColors">["0x53a051","0xdc4e41"]</option>
      </single>
    </panel>
  </row>
</dashboard>

 

0 Karma

Bleepie
Communicator

@ITWhisperer Hello Sensei, could you take another look at this 🙏?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You need to include range as an output field (single will only display values from the first field but can use other fields for the colouring)

| table msg range
0 Karma

Bleepie
Communicator

image_2021-12-06_104954.png

 

This is the result

0 Karma

Bleepie
Communicator

I have applied range ( | table msg range) and even though the coloring works, the text is either severe (red) or low (green) where I would expect Scan not succesful (red) / Scan succesful (green). Any thoughts?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Go back to

| table msg range

and remove this line

        <option name="field">range</option>

 

0 Karma

Bleepie
Communicator

Works! Thanks

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Single is using the first two fields so put count as the first

| table count msg range
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...