Elasticsearchã«mappingãtemplateè¨å®ãã¦ã¿ã
Elasticsearchã¯ã¹ãã¼ãã¬ã¹ãªã®ã§ãã®ã¾ã¾ãã¼ã¿çªã£è¾¼ãã§ãåãã¾ããã
ããã©ã«ãã ã¨Stringã¨ãã¦åãè¾¼ã¾ããããç¡é§ã«è¦ç´ 解æããã¾ãã
å¹çãæ¤ç´¢æ§ãèãã¦é¨åçã«ã¹ãã¼ããå
ã«è¨å®ãã¦ããã¾ãã
èªåã®å ´åãä»åã¯Apacheãªãã°ã ã£ãã®ã§ã
ã»request_time:ãã°æ¥ä»ãdate_formatã§èªèãããã
ã»req_size, response_time: æ°åã¨ãã¦èªèãããã
ã»protocol, method, code: è¦ç´ 解æããªã
ã¿ãããªmappingãè¨å®ããã¾ããã
ãªããres_sizeãæ°åã«ããããã£ãã®ã§ããã
method:HEADã¿ãããªæã«ã-ããå
¥ã£ã¦ãã¦ãã¾ã£ã¦ParseErrorã ã£ãã®ã§ã
ã¨ããããä»ã¯Stringã§ææ
¢ãã¦ãã¾ãã
ã¨ãããã¨ã§æ¸ããã®ã¯ä»¥ä¸ã
{ "template_1" : { "template" : "*", "mappings" : { "apache" : { "properties" : { "protocol" : { "type":"string", "index":"not_analyzed" }, "request_time" : { "type":"date", "format":"dd/MMM/YYYY:HH:mm:ss Z" }, "method" : { "type":"string", "index":"not_analyzed" }, "code" : { "type":"string", "index":"not_analyzed" }, "res_size" : { "type":"string" }, "req_size" : { "type":"integer" }, "response_time" : { "type":"integer" } } } } } }
"apache"ã®é¨åãtypenameã"properties"ã®ä¸ã®é層ãåè¨å®è¦ç´ ã
"template"ã®å¤ã¯ãããããããindexã®ãã¿ã¼ã³ã ã£ãããªï¼
è¨å®å
容ã¯ã ãããè¦ãã¨ãããã¾ããï¼
"mapping"以ä¸ã®é¨åãガイドã®ããã«curlã§ç´æ¥è¨å®ãã§ããããã§ããã
indexãlogstashå½¢å¼ã§ããããããããæã«èªåçã«é©ç¨ãããããã«ãããã£ãã®ã§
templatesã¨ããã®ã試ãã¦ã¿ã¾ããã
ä¸ã®ãtemplate_1.jsonã¨ãã¦ä»¥ä¸ã®ãã¹ã«é ç½®ãã¾ãã
/<elasticsearch_dir>/config/templates/template_1.json
ãã¡ã¤ã«åã¨1ã¤ç®ã®è¦ç´ ãä¸ç·ã§ãªãã¨ãã¡ãã©ããã¯è©¦ãã¦ã¾ããã
é
ç½®ãã¦elasticsearchãåèµ·åããã°è¨å®ãé©ç¨ãããã¯ãã§ããã
注æç¹ã¨ãã¦ããã®æç¹ã§ã¯è¨å®ã確èªãããã¨ãåºæ¥ã¾ããã
ä¾ãã°curlã§mappingï¼indexä½æããå ´åãå½è©²indexã®statusæ
å ±ãheadçã§è¦ãã¨
mappingãè¨å®ããã¦ãããã¨ã確èªãããã¨ãåºæ¥ã¾ãã
ãããtemplateã使ã£ãå ´åã¯è¨å®ãããã®ã¯indexãä½æãããæãªã®ã§
indexãå¥éä½ã£ã¦ã¿ãªãã¨æ¬å½ã«é©ç¨ããã¾ããããã¯ç¢ºèªã§ãã¾ããã
jsonã«ä¸åãããå ´åã¯ãããªã失æããã®ã§ã¡ããã¨äºåã«è©¦ãã¾ãããã
ï¼è¿½è¨ï¼ãã¼ã¹æ¬¡ç¬¬ã§ã¯ãã°æ¥ä»ã®mappingã¯ä¸è¦ã§ããããâ「fluentd-plugin-elasticsearchでのログ時刻の扱い」