I'm new to elasticsearch, so I apologize if my question is trivial
I would like to dinamically change the image displayed in a canvas basing on the last field "value" I've received in my dataset (value < 0 I wish to display image1, value > 0 image2):
I am doing the exact same thing in a test Canvas right now. The reveal image definition:
filters
| timefilter from="now-1m" to="now" column="@timestamp"
| essql
query="SELECT \"HADR_ROLE\" FROM \"logstash-*\" WHERE \"host\" LIKE 'myhostname' AND \"HADR_ROLE\" LIKE 'PRIMARY' ORDER BY \"@timestamp\" DESC LIMIT 1"
| math "size(HADR_ROLE)"
| revealImage origin="bottom" image={asset "asset-aa63dc33-0dad-4d6c-98bf-b26e0322294d"} emptyImage={asset "asset-79bd30df-9d8d-4a4c-b4bc-8d155bf06e85"}
| render
So I select from my index whether a field with a certain value exists, limiting the result to 1. If the result is 1, that equals 100%, showing the full image. If the result is 0, it shows the other image. I do not get any results between 0 and 1, so that is fine.
@BennyInc your solution sounds good if you have to choose between two images, but what about three or more ones?
Conditional example on Github works fine but it uses static images and the demodata mock data set: if I want get data from an index pattern I can't...no data sources can be attached to image element
So trying to continue using reveal image (the query return a number, I try to display one of three images according to the number is = > or < than zero):
filters
| essql
query="SELECT value FROM \"realtimedatatest*\" AS value ORDER BY \"@timestamp\" DESC LIMIT 1"
| switch
{case if={compare gt to= 0} then= "asset-fd9c7e6d-b4ff-44a4-9462-fd442745e206"}
{case if={compare eq to= 0} then= "asset-ff782b14-7eec-40d5-ba29-81cdcad9cd86"}
{case if={compare lt to= 0} then= "asset-eadebace-b7a6-4aba-85ab-3fc7fe86b9ea"}
default = "asset-eadebace-b7a6-4aba-85ab-3fc7fe86b9ea"
}
| math "size(RETURNED_ASSET)"
| revealImage origin="bottom" image={asset RETURNED_ASSET} emptyImage={asset RETURNED_ASSET}
| render
my problem is to inject the returned string by swich where I've RETURNED_ASSET
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.