Conditional change in canvas shape BG colour for the data fetched from Jenkins

New to Kibana, I am pushing my Jenkins log to Logstash and tring to create a canvas in Kibana using shape. through essql i am able to fetch build number and build status. Depending on build status I want to change the background color of the shape and display the build number in the shape. Here build number and status both are string. Currently I am able to display the Build number and Status using markdown, but in CSS its not allowed to make any conditional change so not able to change the BG color of shape. Can someone please help me with this.

Hi, you can use a conditional style in a container style if you want but you have to pipe the whole expression again into the condition, let me show you an example:

filters
| demodata
| math "unique(country)"
| metric "Countries" 
  metricFont={font size=48 family="'Open Sans', Helvetica, Arial, sans-serif" color="#000000" align="center" lHeight=48} 
  labelFont={font size=14 family="'Open Sans', Helvetica, Arial, sans-serif" color="#000000" align="center"} metricFormat="0,0.[000]"
| render containerStyle={containerStyle border="  #1ea6dc" backgroundColor={filters | demodata | math "unique(country)" | if {gt 10} then="red" else="green"}}

the backgroundColor of the containerStyle of this metric visualization can be red or green if the output of the expression filters | demodata | math "unique(country) is greater then 10.

Or you can apply conditional CSS with something similar to:

| render css={filters | demodata | math "unique(country)" | if {gt 10} then=".canvasRenderEl{background: red;}" else=".canvasRenderEl{background: green;}"}
1 Like

Thanks a lot Mark!!, It really helped me.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.