带有百分比计算的Kibana仪表板

时间:2019-09-27 05:15:02

标签: elasticsearch kibana-7

我有一个index,其中包含学生的出勤数据。

{
  "date" : "24/07/2018",
  "Total students" : 30,
  "present" : 10,
  "absent" : 20
},
{
  "date" : "24/08/2018",
  "Total students" : 40,
  "present" : 20,
  "absent" : 20
}

我想在Kibana visualize中为以下各项创建仪表板:

  1. 缺席的学生百分比(按月汇总)
  2. 按月汇总的在校学生百分比

elastic search查询可能如下:

POST students_data/_search
{
    "size": 0,
    "aggs" : {
        "agg_per_month" : {
            "date_histogram" : {
                "field" : "date",
                "calendar_interval" : "month"
            },
            "aggs": {
                "total_students": {
                    "sum": {
                        "field": "Total students"
                    }
                },
                "tot_absentees": {
                  "sum": {
                        "field": "absent"
                    }
                },
                "absentees-percentage": {
                    "bucket_script": {
                        "buckets_path": {
                          "param_tot_absentees": "tot_absentees",
                          "param_tot_students": "total_students"
                        },
                        "script": "params.param_tot_absentees / params.param_tot_students * 100"
                    }
                }
            }
        }
    }
}

我不知道如何在Kibana可视化工具中完成此操作

0 个答案:

没有答案