【发布时间】:2015-08-28 10:32:07
【问题描述】:
我正在尝试使用 kibana 和 ES 分析我的数据库中的时间序列。首先,我使用 python API 将我的数据索引到 ES 中。我使用的映射是:
data= {
"settings":{
"number_of_shards":1,
"number_of_replicas":1
},
"mappings":{
TYPE_NAME: {
"properties":{
"timestamp":{"type":"date", "format":"YYYY-MM-DD HH:mm:ss", "store":"true"},
"current":{"type":"float", "store":"true"},
"bid_qty":{"type":"float", "store":"true"},
"bid":{"type":"float", "store":"true"},
"offer":{"type":"float", "store":"true"},
"offer_qty":{"type":"float", "store":"true"},
"change":{"type":"float", "store":"true"},
"value":{"type":"string", "store":"true"}
}
}
}
}
然后我创建了一个索引并使用下面的代码转储了我的数据
es = Elasticsearch()
response = requests.put('http://127.0.0.1:9200/'+INDEX_NAME+'/', data=json.dumps(data))
row_data = ""
for row in rows:
row_data += '{"index":{"_id": "%s"}}\n' %row[0]
row_dict = {}
for i in range(1, len(row)):
row_dict[headers[i]] = str(row[i])
row_data += json.dumps(row_dict)
row_data += "\n"
response = requests.put('http://127.0.0.1:9200/'+INDEX_NAME+'/'+TYPE_NAME+'/_bulk', data=row_data)
加载此数据后,当我尝试在 kibana 中添加此索引时,它会询问我的时间戳字段是否为数据类型,然后我单击创建。但是在发现选项卡中,我根本找不到我的数据。 有趣的是,我将时间戳字段设为类型字符串,并在 ES 中创建一个新索引,然后其所有内容都将作为非时间序列数据加载。但这对我没有多大用处。如果我做错了什么,请建议我。谢谢。
【问题讨论】:
标签: python-2.7 elasticsearch time-series kibana-4