Failed visualize data from Elastic SQL query in Canvas Bar Chart

I create a canvas board and would like to visualize data in "realtime".

My board:

My Datasource SQL query:
SELECT TIMESTAMP, SENSOR, LAST(VALUE) VALUE
FROM "runtime_kibana_stream"
WHERE SENSOR='knife01' OR SENSOR='knife02' OR SENSOR='knife03'
GROUP BY TIMESTAMP, SENSOR
ORDER BY TIMESTAMP DESC

Datasource preview ist correct:
image

But my bar chart show me not the LAST value of the data.

Idea where ist the Problem?

thx
Otto

Hey @ofitz, what do you have selected for the Y-axis? Using the following shows me the expected data:

Hi Brandon, if you get the FIRST value on Y-axis and add new Value to knife01 with new timestamp which is smaller then 5, the bar chart dont visualized it. The bar chart stays on 5 @ knife01 :frowning:

Would you mind providing a screen-shot of what you're seeing because I'm afraid I'm misunderstanding what you're describing. The ORDER BY TIMESTAMP DESC will always make the most recent value for "knife01" show up.

thx Brandon, to get the last value failed on stream processing on kafka after reboot the server ist works, and with the FIRST value on y-axis i get the actually value :slightly_smiling_face:

The next problem is with the x-axis which i get. The name of the sensors have no static position on the x-axis. in this Video you can see that. In the middle of the video you can see the sensor names and bars are change the position. I would like static postion on x-axis and variable y-axis

Any idea?

By the way, can i change each bar chart color? or change the color of one bar is over of a specific value?

Try this expression and see if it produces the correct results you're looking for:

filters
| essql 
  query="SELECT TIMESTAMP, SENSOR, LAST(VALUE) VALUE
FROM \"runtime_kibana_stream\"
WHERE SENSOR='knife01' OR SENSOR='knife02' OR SENSOR='knife03'
GROUP BY TIMESTAMP, SENSOR
ORDER BY TIMESTAMP DESC"
| ply by=SENSOR fn={math "first(VALUE)" | as "VALUE"}
| pointseries x=SENSOR y=VALUE
| plot
| render

What the ply function is doing here is it's grouping your datatable by SENSOR and applying the fn subexpression to each group. Here the fn is using TinyMath to grab the first value in the VALUE column, which grabs the newest row since your datasource is sorted in descending order by TIMESTAMP.

It should update with date as new documents come in.

Side note: I don't think the GROUP BY TIMESTAMP, SENSOR is necessary in your ESSQL query unless you expect to have multiple documents for the same exact timestamp per sensor.

Hi Catherine_Liu, i tried your expression, but the position on the x.axis continues change.

in this screenshot you can see my streamingdata to ES:

my expression filter are:

I need the expression GROUP BY TIMESTAMP, SENSOR without this expression i get this:

To maintain the same order of values in the x-axis, try adding a sort function in between ply and pointseries to sort the SENSOR field in asc order.

filters
| essql 
  query="SELECT TIMESTAMP, SENSOR, LAST(VALUE) VALUE
FROM \"runtime_kibana_stream\"
WHERE SENSOR='knife01' OR SENSOR='knife02' OR SENSOR='knife03'
GROUP BY TIMESTAMP, SENSOR
ORDER BY TIMESTAMP DESC"
| ply by=SENSOR fn={math "first(VALUE)" | as "VALUE"}
| sort by=SENSOR
| pointseries x=SENSOR y=VALUE
| plot
| render

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