Dashboards & Visualizations

How to change font color on a row based on a specific value?

mmwells
Explorer

I am trying to write simple XML code that will evaluate a field value and change the font color for the row that contains the value. I only need to evaluate two conditions. Alarm or clear. I am new to xml. I could really use some help.

Labels (1)
0 Karma

SanjayReddy
SplunkTrust
SplunkTrust

Hi @mmwells 

following post might help you 

https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-font-color-based-on-a-condit... 

 

----
Regards,
Sanjay Reddy

----
If this reply helps you, Karma would be appreciated

mmwells
Explorer

Sanjay,

 

I tried that but when I tried to validate the code there was an error. I'm not sure how to proceed. I am quite new to using XML.

0 Karma

SanjayReddy
SplunkTrust
SplunkTrust

Hi @mmwells 

Can you please share the error you are getting?.

also please find following XML code i found it in community last time.
using this create a dashboard , and update the query and clour as needed

sample output 

SanjayReddy_0-1684578635079.png

<dashboard version="1.1">
<label>Colour entire row based on value</label>
<row>
<panel>
<html depends="$alwaysHideHTMLCSSPanel$">
<style>
#tableColorFinalRowBasedOnData table tbody td div.multivalue-subcell[data-mv-index="1"]{
display: none;
}
</style>
</html>
<table id="tableColorFinalRowBasedOnData">
<search>
<query>index=_internal source="C:\\Program Files\\Splunk\\var\\log\\splunk\\splunkd.log"
| stats count by component log_level

| eval color=case(log_level="INFO","#00FF00",log_level="WARN","#FFBF00",log_level="ERROR","#FF0000")
| foreach component log_level count [ eval &lt;&lt;FIELD&gt;&gt;=mvappend('&lt;&lt;FIELD&gt;&gt;',color)]
| fields - color</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
<sampleRatio>1</sampleRatio>
</search>
<option name="count">100</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">none</option>
<option name="percentagesRow">false</option>
<option name="refresh.display">progressbar</option>
<option name="rowNumbers">false</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
<format type="color" field="log_level">
<colorPalette type="expression">mvindex(value,1)</colorPalette>
</format>
<format type="color" field="component">
<colorPalette type="expression">mvindex(value,1)</colorPalette>
</format>
<format type="color" field="count">
<colorPalette type="expression">mvindex(value,1)</colorPalette>
</format>
</table>
</panel>
</row>
</dashboard>



----
Regards,
Sanjay Reddy

----
If this reply helps you, Karma would be appreciated

mmwells
Explorer

This one was able to validate. But it doesn't give me quite what I'm looking for. It changes the row color and I just want to change the font color.

0 Karma
Get Updates on the Splunk Community!

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...