I have two columns in a table host and status
my status column has value 200 and 404
So based on the status column on every host i want to color the host cell.
i don't want to color status cell or display it. I just want to display host filed and it should be colored based on status value.
I was looking for a solution to similar problem and came across your post.
See example here to do the coloring - https://answers.splunk.com/answers/820403/how-to-change-font-color-based-on-a-condition-for.html.
Then use fields option in simple xml to show only the columns you want. Have fun!
@vn86893 refer to one of my answers below. With the suggestion from @kamlesh_vaghela you would be able to get the desired output as expected, however, it requires JS and CSS. If your constraint is to avoid static files like JS and CSS, you can try the other option as proposed in the answer. However, you would see status and host field value also in the table.
https://answers.splunk.com/answers/686288/how-do-you-highlight-a-table-cell-based-on-a-field.html (refer to the first example which does not use JS
and applies color via colorPalette using Expressions purely through Simple XML, available in Splunk 6.5 and above ).
Hi @vn86893,
You don't need CSS to achieve this. You can do it using this guide from the documentation:
It's quite easy, let me know if you manage to do it or if you need more help.
Cheers,
David
Thanks For your response David. In the above example looks like you are manually color coding item ID and Category ID. and sorting count based on value. My requirement is a bit different. I need to color Category ID based on count. Lets say the count is between 100 and 150 let the category ID color be red etc..
Hi @vn86893,
You're welcome. The threshold configuration is also in that same document, around the beginning, here :
https://docs.splunk.com/Documentation/Splunk/7.3.1/Viz/TableFormatsXML#Color_scale_types_and_options
Just collapse the threshold
and you'll get this config:
<format type="color" field="purchase_count">
<scale type="threshold">0,30,70,100</scale>
</format>
You can then combine that with color palette to give the colors based on the threshold.
Is that what you're looking for ?
Correct me if I'm wrong, but your sample would only allow @vn86893 to color the status column. I don't think you can color the host (or any other column) based on the status value without JS.
The Splunk Dashboard Examples app (https://splunkbase.splunk.com/app/1603/) has an easy copy and paste JavaScript dashboard that accomplishes this (they color the whole row based on a single cell's value, but it's similar enough).
@vn86893
Please check my answer in the below post.
https://answers.splunk.com/answers/661894/how-to-color-cell-contents-with-css-and-js.html
Is there a way we can achieve this without using any Js or CSS ??