首页 > 解决方案 > 使用分位数数据草图聚合器时德鲁伊的空响应

问题描述

我正在尝试计算德鲁伊指标的第 95 个百分位值。我遇到了这个文档https://druid.apache.org/docs/latest/development/extensions-core/datasketches-quantiles.html,它说我们可以在查询时从原始数据构建草图。

我准备了这个德鲁伊查询

{
    "queryType": "timeseries",
    "intervals": [
        "2020-05-08T11:45:00.000Z/2020-05-08T11:50:00.000Z"
    ],
    "granularity": "minute",
    "dataSource": "datasource",
    "filter": {
        "type": "selector",
        "dimension": "hostName",
        "value": "host"
    },
    "postAggregation": [
        {
            "type": "quantilesDoublesSketchToQuantile",
            "name": "dim",
            "field": "dim",
            "fraction": 0.5
        }
    ]
}

但是当我触发这个查询时,我得到了来自德鲁伊的空洞响应。输出是

[
  {
    "timestamp": "2020-05-08T11:45:00.000Z",
    "result": {

    }
  },
  {
    "timestamp": "2020-05-08T11:46:00.000Z",
    "result": {

    }
  },
  {
    "timestamp": "2020-05-08T11:47:00.000Z",
    "result": {

    }
  },
  {
    "timestamp": "2020-05-08T11:48:00.000Z",
    "result": {

    }
  },
  {
    "timestamp": "2020-05-08T11:49:00.000Z",
    "result": {

    }
  }
]

我验证了数据在该时间范围内存在于 druid 中。提前致谢

标签: druid

解决方案


你有一个postAggregatortype quantilesDoublesSketchToQuantile,你正在传递 field dim。该函数获取草图并在聚合后将其转换为分位数,但它不会构建草图,而是将草图作为输入。您首先需要使用函数创建一个聚合quantilesDoublesSketch,这是您传入的地方dim,然后您可以使用导致您的postAggregator.


推荐阅读