grafana elasticsearch date类型问题

{
    "createTime": 1484967199,
    "ip": "localhost",
    "appId": "10000",
    "threadName": "Thread-acceptor-1",
    "level": "info",
    "type": "error",
    "tag": "tag1",
    "module": "module1",
    "detail": "some description" }
http://132.122.252.22:9200/flume-index/_mapping
{
    "flume-index": { "mappings": { "distributed-log": { "properties": { "appId": { "type": "string" }, "createTime": { "type": "long" }, "detail": { "type": "string" }, "ip": { "type": "string" }, "level": { "type": "string" }, "module": { "type": "string" }, "tag": { "type": "string" }, "threadName": { "type": "string" }, "type": { "type": "string" } } } } } }

没有指定es的mapping,所以根据java类型,当storm推数据到es时则会当做long型,具体格式如下,这导致grafana根据createTime查询错误,需要更改createTime的mapping。

curl -XDELETE 'localhost:9200/flume-index/?pretty'
curl -XPUT 'localhost:9200/flume-index/?pretty' -d 
' { "mappings": { "distributed-log": { "properties": { "appId": { "type": "string" }, "createTime": { "type": "date" }, "detail": { "type": "string" }, "ip": { "type": "string" }, "level": { "type": "string" }, "module": { "type": "string" }, "tag": { "type": "string" }, "threadName": { "type": "string" }, "type": { "type": "string" } } } } } '
curl -XPOST localhost:9200/flume-index -d '
{
    "mappings": {
        "_default_": {
            "_timestamp": {
                "enabled": true
            }
        }
    }
}
'