我目前正在實施Kibana 4(v4.0.0)作爲我們公司的財務儀表板,訂單數據來源於ElasticSearch。我正在努力解決缺乏加權平均度量聚合的問題,以計算特定時間間隔內的毛利率。有可能編寫自定義指標,但Kibana不會在表格可視化構建中顯示/實施自定義指標。Kibana加權平均毛利率
採樣數據的一小可視化:
**Order 1**
Revenue: 1000
Cost of goods sold: 800
Gross margin: 200
Gross margin percentage: 200/1000 = 0.2 (= 20%)
**Order 2**
Revenue: 100
Cost of goods sold: 20
Gross margin: 80
Gross margin percentage: 80/100 = 0.8 (= 80%)
請參考this page for calculation of the gross margin percentage
予設定的毛利率每elasticsearch文件(=訂單對象)的字段。例如,訂單1的'gross_margin'字段等於0.2。簡單地返回'gross_margin'字段的平均值(average aggregation)是不夠的,因爲這將返回0.5((0.2 + 0.8)/ 2),但實際總收益爲0.254(((1000 + 100) - (800 + 20))/(1000 + 100))。
也許這種加權平均值可以通過Kibana通過解決方法實現,但我無法在任何文檔中找到它。如果有人能提供指導,我將不勝感激。當我的問題不清楚時,請不要猶豫,要求提供更多信息。