Hello, I am trying to build a traffic light element inside Canvas.
I am using different variables to control the expression.
However, I found that the variables are not working inside the "Switch" condition blocks.
filters
| essql
query={string "SELECT wlsdomain
FROM " {var "index_wls"} "
WHERE " {var "severity"} "
AND wlscluster LIKE " {var "cluster_dm"} "
AND QUERY('logMessage:" {var "keyword_stuck"} "')
AND \"@timestamp\" > DATE_ADD('seconds', " {var "interval"} ", NOW())"}
| math "size(wlsdomain)"
| metric
metricFont={font underline=false weight="bold" align="center" family="'Open Sans', Helvetica, Arial, sans-serif" italic=false size=20 color={if {all {eq 0}} then="rgba(0,0,0,0)" else="#FFF"}} metricFormat="0,0.[000]"
| render
containerStyle={containerStyle borderRadius="100px" border="rgba(255,255,255,0)"
backgroundColor={filters
| essql query={string "SELECT wlsdomain
FROM " {var "index_wls"} "
WHERE " {var "severity"} "
AND wlscluster LIKE " {var "cluster_dm"} "
AND QUERY('logMessage:" {var "keyword_stuck"} "')
AND \"@timestamp\" > DATE_ADD('seconds', " {var "interval"} ", NOW())"}
| math "size(wlsdomain)"
| switch case={case if={all {eq 0}} then={var "color_normal"}}
case={case if={all {gt 0} {lte {var "threshold_warn_st"}}} then={var "color_warn"}}
case={case if={all {gte {var "threshold_alert_st"}}} then={var "color_alert"}}
default={var "color_normal"}
}
}
According to the attached screenshot, the value of the element is equal to 40. It is greater than or equal to 4 ( {var "threshold_alert_st"} ). So based on the condition inside the Switch, it should turn to red color ( {var "color_alert"} ). However, it still in green color.
Several foundings:
- The variables "threshold_warn_st" and "threshold_alert_st" are not working inside the condition.
- The other variables outside the Switch condition block are worked properly. (e.g. {var "color_warn"} )
So may i know how to parse the variable inside the condition correctly? Thank you so much.
Regards,
Isaac