I have an issue with adding the HTML code in my Splunk dashboard. The code is to set the color to a specific field/column in a panel with table representation.
I have added the below code, which is working fine for the number field (COUNT)
<format type="color" field="COUNT">
<colorPalette type="minMidMax" maxColor="#D6563C" minColor="#FFFFFF">
</colorPalette>
<scale type="minMidMax"></scale>
</format>
I would like to add the same code for a field which represents the time duration in the format of "HH:MM:SS". The above code is not supporting the time format.
Could anyone please help me in getting the right code to support the time format fields also.
[UPDATED ANSWER]
Try the answer for applying colorPalette based on expression where cell value is split into two values (multi value field) and value at second index is used for coloring (can use eval expression to color):
https://answers.splunk.com/answers/820403/how-to-change-font-color-based-on-a-condition-for.html
JS will obviously also work! Please try both approaches and confirm!
@akarivaratharaj since your requirement is complex not based on direct values of data SimpleXML colorPalette settings including "expression"
will not be sufficient for your.
Refer to one of my older answers using Simple XML JS Extension with Splunk JS Stack to override Table Cell rendering. I have applied Color to the row, but you can restrict the same to specific cell as well: https://answers.splunk.com/answers/581747/change-row-color-when-the-field-time-value-increas.html
Hi @niketn
Now, my dashboard panel has the time duration values with the format as "HH:MM:SS.FF" as below:
Type, Count, Duration
A, 20, 05:10:33.40
B, 50, 04:59:02.66
C, 10, 01:28:57.51
I need the column `Duration` has to be color coded based on highest to lowest duration range.
Is there any possibility to get the color coding without using any Java Script
I think you should use something like this :
<format type="color" field="Time">
<colorPalette type="expression">if(strptime(value,"%H:%M:%S")>"3600", "#0000CC", "#65A637")</colorPalette>
</format>
You might have to change the condition acordingly. but this should be the way to define the expression for time. You could use different conditions using nested if.
let me know if this helps!
@mayurr98 Already I have defined the time duration column with some mathematical expressions which I required in my query and that I am displaying in the table format. I wanted the rows of the table to be sorted as high to low time duration and upon that to highlight the highest value of duration I wanted to use the colouring.
Now, I have my table records as below:
Type, Count, Duration
A, 20, 05:10:33
B, 50, 04:59:02
C, 10, 01:28:57
Here, I want to add the color to my existing field "Duration". Could anyone please help me on this.