Calculate average in Kibana visualizations

Hello,

I have a set of records which include

  • times - how much times the event has been executed
  • time_sum - sum of events execution time.

Such events are published with interval of 5 seconds. I would like to visualize an average of execution time for every 5 minutes. What I should do is sum(times) for 5 minutes / sum(time_sum) for 5 minutes for each 5 minutes. Does Kibana allow to do It using regular Kibana visualizations?

PS. I use Micrometer library for publishing metrics to Elasticsearch. And I asked the Micrometer's developers to give an ability to set different reporting step for metrics to avoid such aggregations on Kibana side. Here is the link.

Hi,

what you are looking for is the bucket script aggregation, which allows you to calculate the outcome of several metric aggregations. This is not yet completely implemented in Kibana, see also https://github.com/elastic/kibana/issues/4707

Nevertheless you could actually achieve that (using Bucket Script aka Calculation) in Visual Builder, where you would just create two sum aggregations (for times and time_sum) and then create a script, that will divide those two and draw this one.

The same could also be achieved in the more stable timelion visualization, by using a script that looks something like:

.es(metric=sum:times).divide(.es(metric=sum:time_sum))

And switching the interval selector to using 5m.

Cheers,
Tim

Thank you for answer. I did It using Visual Builder. Very cool stuff! And the chart looks better than regular Kibana visualization!

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