【问题标题】:How to use elasticsearch nested aggregations in kibana visualizations如何在 kibana 可视化中使用 elasticsearch 嵌套聚合
【发布时间】:2019-08-25 11:34:55
【问题描述】:

我在 elasticsearch 中有以下搜索,它返回我需要的嵌套数据结构上的聚合,但我真的想在 kibana 中将其用作可视化,但我不知道如何做到这一点:

GET /system_data_nested/_search
{
  "size": 0,
  "aggs": {
    "consideration": {
      "nested": {
        "path": "children"
      },
      "aggs": {
        "gross": {
          "sum": {
            "field": "children.executions.consideration"
          }
        }
      }
    }
  }
}

返回

{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 920,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "consideration": {
      "doc_count": 486,
      "gross": {
        "value": 4492767
      }
    }
  }
}

理想情况下,我可以使用水平条形图按日期直方图汇总每个时间段以供考虑。

这可能吗?

【问题讨论】:

    标签: elasticsearch kibana elastic-stack elasticsearch-aggregation


    【解决方案1】:

    实际上,是的,这是可能的。我遇到了类似的问题并使用Vega 可视化解决了它(另请查看introduction video)。它的作用是向 Elasticsearch 发送自定义查询,让您决定要可视化响应的哪一部分。

    在你的情况下,它看起来有点像这样(注意,这是HJSON):

    {
      $schema: https://vega.github.io/schema/vega-lite/v2.json
      title: Engine Score over Time
      // Define the data source
      data: {
        url: {
          index: system_data_nested
          body: {
            "size": 0,
            "aggs": {
              "consideration": {
                "nested": {
                  "path": "children"
                },
                "aggs": {
                  "gross": {
                    "sum": {
                      "field": "children.executions.consideration"
                    }
                  }
                }
              }
            }
          }
        }
        format: {
          "property": "aggregations.consideration"
        }
        mark: line
        encoding: {
          x: {
            field: key
            type: temporal
            axis: { "title": "Date" }
          }
          y: {
            field: gross.value
            type: quantitative
            axis: { "title": "Consideration" }
          }
        }
      }
    }
    

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2020-02-12
      • 2019-01-24
      • 2014-08-10
      • 2016-02-29
      • 1970-01-01
      • 2020-06-12
      • 2021-12-14
      • 2015-11-18
      • 1970-01-01
      相关资源
      最近更新 更多