[ElasticSearch DataSource]Dividing two elasticsearch metric series and groupby device

I need to devid two metric series( sum( hit request number)/ sum(total request number) ) which are groupby device id.
Get hit percent of each device, and show bottom five devices.

How can I do it in Grafana editor?
Thanks anyway