Average on current visualization

Good evening, i'm trying to make a simple average but maybe i'm focused on a wrong way that is been leading me astray.
I'm using Kibana to show some productivity data coming from a industrial production plant.
I've in elasticsearch all the orders processed with the total pieces produced and the total time duration of order.
Now, viewing data in kibana dashboard also with some scripted fields works good but i need to make a productivity average on the documents selected by dashboard filters.
For example orders of today:

  1. Order num 1 - 100 pieces - 20 minutes
  2. Order num 2 - 200 pieces - 30 minutes
  3. Order num 3 - 100 pieces - 25 minutes

If i create a scripted fields that calculates the piecese/minutes it works good but it's not the data i want. I need to make the sum of piecese and the sum of time and calculate average over it.

What is the best way to do this?

Thank's in advance for your help!

You should be able to do so by using Timelion visualizations. Something along the lines of what's below should return a 5.3 average by summing up the total pieces / total time within a day's interval.

Example:

.sum(.es(index=orders*,timefield=date,metric=sum:numOfPieces)).divide(.es(index=orders*,timefield=date,metric=sum:timeInMinutes))

I believe this is what you're looking for.

Hi, thank you for your answer.
My target is to show this number as a metric/gauge in a dashboard. With timelion i think i can create only chart. Or i'm wrong?
I've seen datasweet plugin for kibana that seems make what i'm searching for but is not supported in kibana 7.4

Hi @gibo,

Unfortunately to display a single number based on this kind of calculation, canvas would be your best bet. Though, adding a canvas to a dashboard isn't supported just yet.

I've found a plugin that works good.extended metrics. Problem solved!