Kibana - Pie-Chart with sum over two different fields

时光怂恿深爱的人放手 提交于 2019-12-12 03:27:25

问题


In an index I have two mappings.

"mappings" : {
    "deliveries" : {
        "properties" : {
            "@timestamp":  { "type" : "date", "format": "yyyy-MM-dd" },
            "receiptName" : { "type" : "text" },
            "amountDelivered" : { "type" : "integer" },
            "amountSold" : { "type" : "integer" },
            "sellingPrice" : { "type" : "float" },
            "earned" : { "type" : "float" }
        }
    },
    "expenses" : {
        "properties" : {
            "@timestamp":  { "type" : "date", "format": "yyyy-MM-dd" },
            "description": { "type" : "text" },
            "amount": { "type": "float" }
        }
    }
}

Now I wanted to create a simple Pie Chart in Kibana for sumarize up deliveries.earned and expenses.amount.

Is this possible or do I have to switch to an client application? The number of documents (2 or 3 a month) is really to less to start some development here xD


回答1:


You can create a simple scripted_field through Kibana which maps amount and earned fields to the same field, called transaction_amount.

Painless script:

if(doc['earned'].length > 0) { return doc['earned']; } else { return doc['amount']; }

Then you can create a Pie Chart with "Slice Size" configured as the sum of transaction_amount and "Split Slices" configured as a Terms Aggregation on _type.



来源:https://stackoverflow.com/questions/44470978/kibana-pie-chart-with-sum-over-two-different-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!