Bucket aggregation - calculate my own metric inside bucket

i collect data from my router and store into Elasticsearch.

My data mappings are in this form : < {"interface_name":"keyword", "value":"double", "timestamp":"integer"}. >

I need to measure flow for each interface like: < flow = (v2-v1)/(t2-t1) >.

So if i have for an example two interfaces with same name
(interface:"i1" value: 5 ts: 2) and (interface: "i1" value:10 ts:3 ) i need to get (10-5)/(3-2) as output.

I group each interface into bucket with bucket aggregation and i know how to get avg/max/min, but i don't know how to calculate with my own formula.

This is my first post on forum,
Thank you in advance!

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