Splunk Search

Color individual table cell based on value of other table cell

Marcovd
Explorer

I have a table with different columns like:
C1 C2 C3 C1Code C2Code C3Code

I would like to color the cell in a column (C1, C2 or C3) depending of the value in the cells C1Code, C2Code or C3Code.
(I'm able to color the cell C1Code, C2Code and C3Code depending on the value of those cells)

Tags (3)
1 Solution

vganjare
Builder

If you are using cell renderer, you can combine fields C1 and C1Code into one (seperated by delimeter). Use this field in column C1. In the JS, when you read this field, extract the value for C1 and C1Code (by splitting at delimeter). Replace the cell text with C1 value and set the cell color using C1Code.

Thanks!!

View solution in original post

vganjare
Builder

If you are using cell renderer, you can combine fields C1 and C1Code into one (seperated by delimeter). Use this field in column C1. In the JS, when you read this field, extract the value for C1 and C1Code (by splitting at delimeter). Replace the cell text with C1 value and set the cell color using C1Code.

Thanks!!

Marcovd
Explorer

Hi vganjare, thanks for your fast answer, but can you please explain some more?

Where do I combine the columns, in the search in splunk?
Can you maybe give me an example of the .js code?

Thanks

0 Karma

Marcovd
Explorer

Solved it like vganjare suggested 🙂

  • Added | eval C1=C1 +";" + C1Code to the search
  • Added cell.value.split(";")[1] to the javascript
  • Added $td.text(cell.value.split(";")[0]) to the javascript

Thanks vganjare

Get Updates on the Splunk Community!

Fueling your curiosity with new Splunk ILT and eLearning courses

At Splunk Education, we’re driven by curiosity—both ours and yours! That’s why we’re committed to delivering ...

Splunk AI Assistant for SPL 1.1.0 | Now Personalized to Your Environment for Greater ...

Splunk AI Assistant for SPL has transformed how users interact with Splunk, making it easier than ever to ...

Unleash Unified Security and Observability with Splunk Cloud Platform

     Now Available on Microsoft AzureOn Demand Now Step boldly into the AI revolution with enhanced security ...