Elasticsearch日期直方图,包含时区和扩展边界

时间:2017-07-18 09:17:21

标签: elasticsearch grafana

在Elasticsearch 2.x中,我进行了日期直方图聚合,我需要同时设置time_zoneextended_bounds选项:

...
"date_histogram": {
  "interval": "1d",
  "field": "time",
  "min_doc_count": 0,
  "format": "epoch_millis",
  "time_zone": "Europe/Rome",
  "extended_bounds": {
    "min": "1496268000000",
    "max": "1498859999999"
  }
}
...

它返回错误failed to parse date field [1496268000000] with format [epoch_millis],但它对我没有意义,因为该值实际上以毫秒为单位

{
  "error": {
    "root_cause": [
      {
        "type": "parse_exception",
        "reason": "failed to parse date field [1496268000000] with format [epoch_millis]"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "[...]",
        "node": "[...]",
        "reason": {
          "type": "parse_exception",
          "reason": "failed to parse date field [1496268000000] with format [epoch_millis]",
          "caused_by": {
            "type": "illegal_argument_exception",
            "reason": "Parse failure at index [0] of [1496268000000]"
          }
        }
      }
    ]
  },
  "status": 400
}

我实际上正在使用Grafana并尝试找到this problem的解决方法。

1 个答案:

答案 0 :(得分:0)

我已经解决了我的问题:扩展边界的minmax必须是数字,而不是字符串:

"extended_bounds": {
  "min": 1496268000000,
  "max": 1498859999999
}

如上所述,我正在使用Grafana,因此问题来自那里。 This pull request解决了问题(请参阅对datasource.js的更改)。