Kibana-带有两个不同字段之和的饼图 [英] Kibana - Pie-Chart with sum over two different fields

查看:428
本文介绍了Kibana-带有两个不同字段之和的饼图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在索引中,我有两个映射.

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.earnedexpenses.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆