Hi.
I have next script panel. I have saved limit values to csv. For ex. gc_perc90_standart=0.01. I need to color cell in green if value < 0.01 and red if more. But problem here - if (value > gc_perc90_standart, "#53A051", "#DC4E41")
How I should use variable within colorPalette?
<panel depends="$tok_GC_statistic$">
<title>GC statistics in seconds</title>
<table>
<search>
<query>
index="all" source="*/log/gc_log_memory.log"
| rex "Total time for which application threads were stopped:\s(?<GC_TIME_THREADS>[0-9]+\.{0,1}[0-9]*)\sseconds"
| stats count(GC_TIME_THREADS) as cntGC, perc90(GC_TIME_THREADS) as proc90GC by host
| join type=inner
[
| inputlookup gc_standarts.csv | fields gc_perc90_standart
]
| table host cntGC proc90GC gc_perc90_standart
</query>
<earliest>$TimeToken.earliest$</earliest>
<latest>$TimeToken.latest$</latest>
<sampleRatio>1</sampleRatio>
</search>
<option name="count">20</option>
<option name="drilldown">cell</option>
<format type="color" field=proc90GC >
<colorPalette type="expression">if (value > gc_perc90_standart, "#53A051", "#DC4E41")</colorPalette>
</format>
<drilldown>none</drilldown>
</table>
</panel>
@vyulun
Can you please check my answer on below link? I have used Javascript and CSS to achieve same requirement. Let me know for any further assistance.
Thanks
thx, I will try css.
@vyulun
Can you please try this?
<format type="color" field=proc90GC >
<colorPalette type="expression">if (value > 'gc_perc90_standart', "#53A051", "#DC4E41")</colorPalette>
</format>
My Sample Code :
<dashboard>
<label>test</label>
<row>
<panel>
<table>
<search>
<query>index=main |stats count by sourcetype | eval step=20000</query>
<earliest>-30d@d</earliest>
<latest>now</latest>
<sampleRatio>1</sampleRatio>
</search>
<option name="count">20</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">row</option>
<option name="percentagesRow">false</option>
<option name="rowNumbers">false</option>
<option name="wrap">true</option>
<format type="color" field="count">
<colorPalette type="expression">if (value > 'step',"#FF5733","#247bc1")</colorPalette>
</format>
</table>
</panel>
</row>
</dashboard>
Thanks
also with constant works correct
.... if (value > 0.01, .....
I have made experiment with integers (1 2 3...), but the same problems
@vyulun
Can you please share sample output of your search??
@vyulun
I have tried with the same. Yes it is working if we defined hard coded value. But it is not when we mentioned field name. I think we can only use value of that field which in mentioned in colorPalette
tag.
I have posted another answer to this question. I have achieved same thin using Javascript & CSS. Can you please check the same?
Hi, kamlesh_vaghela. Thx for help. But, unfortunatelly, not resolve my problem. All values are red. Maybe because gc_perc90_standart is float value == 0.01?
Splunk version 7.1.2.