首页 > 解决方案 > bdcsv.py 返回“日期时区 id '00:00' 未被识别”

问题描述

我正在尝试运行bdcsv.py

$ sudo python /opt/bluedata/bundles/bluedata-epic-entdoc-minimal-release-3.7-2207/scripts/monitoring/bdcsv.py \
     -c localhost \
     -f cred.json \
     -s 2018/02/07-00:00:00 \
     -e 2018/02/07-23:59:59

我在使用自己的开始和结束值时收到以下错误,因此对于这篇文章,我使用了BlueData 文档中示例中的开始和结束值。

运行上述返回以下错误(我已格式化 json 以使其更具可读性):

processing data for virtual node: bluedata-40 ...
error: {  
   "error":{  
      "root_cause":[  
         {  
            "type":"parsing_exception",
            "reason":"[date_histogram] failed to parse field [time_zone]",
            "line":1,
            "col":477
         }
      ],
      "type":"parsing_exception",
      "reason":"[date_histogram] failed to parse field [time_zone]",
      "line":1,
      "col":477,
      "caused_by":{  
         "type":"illegal_argument_exception",
         "reason":"The datetime zone id '00:00' is not recognised"
      }
   },
   "status":400
}

知道这里出了什么问题吗?

标签: bluedatabluedata-3.7

解决方案


运行时出现同样的错误bdusage.py

时区似乎以错误的格式传递给 ElasticSearch 查询。在这两个脚本中,您都会发现以下几行(我在行内添加了注释以进行澄清):

tz = time.timezone / 3600 * -1           
if tz < 0:
    tzstr = str(tz).zfill(3) + ":00"     # negative tz will produce strings like "-06:00"
else:
    tzstr = str(tz).zfill(2) + ":00"     # positiv tz will return e.g. "01:00"

tzstr稍后将包含在查询中。您描述的错误仅在时差 >= 0 小时时出现,因为ElasticSearch 要求时区的格式类似于+01:00or -01:00

通过替换上面代码中的最后一行来修复它,如下所示:

tzstr = "+" + str(tz).zfill(2) + ":00"    # positiv tz will now return e.g. "+01:00"

推荐阅读