小编Coo*_*ire的帖子

使用Bulk-API使用Elasticsearch-py向ElasticSearch添加时间戳

我正在尝试为我的数据添加时间戳,使用elasticsearch-py批量索引,然后使用kibana显示数据.

我的数据显示在kibana中,但我的时间戳没有被使用.当我在配置索引模式后进入"发现"选项卡时,我得到0结果(是的,我尝试调整搜索时间).

这是我的批量索引json的样子:

{'index': 
         {'_timestamp': u'2015-08-11 14:18:26', 
          '_type': 'webapp_fingerprint', 
          '_id': u'webapp_id_redacted_2015_08_13_12_39_34',
          '_index': 'webapp_index'
         }
}

****JSON DATA HERE***
Run Code Online (Sandbox Code Playgroud)

这将被elasticsearch接受并将被导入Kibana,但_timestamp字段实际上不会被索引(当在"时间字段名称"下配置索引模式时,它确实显示在下拉列表中).

我也试过像这样格式化metaFields:

{'index': {
           '_type': 'webapp_fingerprint', 
           '_id': u'webapp_id_redacted_2015_08_13_12_50_04', 
           '_index': 'webapp_index'
          }, 
           'source': {
                      '_timestamp': {
                                     'path': u'2015-08-11 14:18:26',
                                     'enabled': True, 
                                     'format': 'YYYY-MM-DD HH:mm:ss'
                                    }
                     }
}
Run Code Online (Sandbox Code Playgroud)

这也行不通.

最后,我尝试在索引中包含_timestamp字段并应用格式,但我在弹性搜索时出错.

{'index': {
           '_timestamp': {
                          'path': u'2015-08-11 14:18:26', 
                          'enabled': True, 
                          'format': 'YYYY-MM-DD HH:mm:ss'
                         }, 
           '_type': 'webapp_fingerprint', 
           '_id': u'webapp_id_redacted_2015_08_13_12_55_53', 
           '_index': 'webapp_index'
          }
}
Run Code Online (Sandbox Code Playgroud)

错误是:

elasticsearch.exceptions.TransportError: 
TransportError(500,u'IllegalArgumentException[Malformed action/metadata 
line [1], expected a simple value for field [_timestamp] …
Run Code Online (Sandbox Code Playgroud)

python elasticsearch kibana kibana-4 elasticsearch-py

4
推荐指数
1
解决办法
4334
查看次数