Kibana-带有两个不同字段之和的饼图 [英] Kibana - Pie-Chart with sum over two different fields
问题描述
在索引中,我有两个映射.
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" }
}
}
}
现在,我想在Kibana中创建一个简单的饼图,以总结deliveries.earned
和expenses.amount
.
Now I wanted to create a simple Pie Chart in Kibana for sumarize up deliveries.earned
and expenses.amount
.
这是否可行,还是必须切换到客户端应用程序?文件数量(每月2或3个)真的很少,因此无法在xD上开始开发
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
推荐答案
您可以创建一个简单的通过基巴纳语编写的字段,它将 amount 和 earned 字段映射到称为 transaction_amount 的同一字段.
You can create a simple scripted_field through Kibana which maps amount and earned fields to the same field, called transaction_amount.
无痛脚本:
if(doc['earned'].length > 0) { return doc['earned']; } else { return doc['amount']; }
然后,您可以创建一个饼图,其中切片大小" 配置为 transaction_amount 和分割切片"的总和配置为 _type 上的 Terms Aggregation .
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.
这篇关于Kibana-带有两个不同字段之和的饼图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!