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
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...