bluedata - 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
}
知道这里出了什么问题吗?
解决方案
运行时出现同样的错误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:00
or -01:00
。
通过替换上面代码中的最后一行来修复它,如下所示:
tzstr = "+" + str(tz).zfill(2) + ":00" # positiv tz will now return e.g. "+01:00"
推荐阅读
- php - 在 Vue 中使用 LoginController.php
- python - Python 3:如何获得一个随机的 4 位数字?
- c# - 以路径为内容的 WPF 按钮
- acumatica - 获取 Acumatica 附加的公共文件而不进行身份验证
- javascript - NodeJS“readline”模块不输出提示
- spring - Spring RestTemplate + Basic Authentication + Post with request Body: 500 Internal Server Error
- java - 在 DataFrame 中执行过滤时如何检查表达式是否有效
- google-drive-api - 将 Google 云端硬盘文件从公开更改为私有
- html - 使用动态表格宽度在滚动时修复表格标题
- javascript - 运行js后重定向