Kibana - Average based on two fields value

you can use Time Series Visual Builder for this. I loaded in a 6.8.2 new instance the flights sample data and created a chart that renders a ratio between the average distance and the average flight time using the Bucket Script aggregation

This blog post also covers pretty well the topic of computing ratios in different Kibana applications.