date型のログをelasticsearchに入れた時にtext型として認識されてしまい、グラフ化できなかった。
このような時、あらかじめ型のフォーマットを定義しておき、その後elasticsearchにログを入れていく。
型のフォーマットの定義は、jsonファイルを用意し、curlでelasticsearchに登録する。
- template.json
{
"template":"hogehoge-index",
"mappings":{
"nginx":{
"properties":{
"local_time":{
"type":"date",
"index":"not_analyzed"
},
"host":{
"type":"keyword",
"index":"not_analyzed"
}
}
}
}
}
$ $ curl -XPUT <ES_ENDPOINT>/_template/hogehoge-index?pretty -d "$(cat template.json)"


