I have what I think should be a relatively straight forward requirement for visualizing data in Kibana. I have an index containing documents which give a price paid per unit and a number of units bought at that price. I need to visualize the average price paid per unit over time as a histogram. That can't be achieved simply by using an average aggregation on the price field, because that doesn't take into account the number of units bought at each price. What I need is: for each document, multiply the price by the number of units, then for each time bucket, divide the total spent (sum of (unit price * units)) by the total number of units sold to get the average price paid per unit.
I can get the total spend for each document (unit price * units) using a scripted field, but I'm unable to then divide total spend by total units to get the average price (scripted fields don't work in TSVB, and apparently never will be.)
Does anyone know of some way of doing this?
Thanks
question from:
https://stackoverflow.com/questions/66050398/visualizing-division-of-two-aggregations-in-kibana 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…