logstash 輸出到elasticsearch 自動創建index

      因爲es 單index 所能承受的數據量有限,以前狀況是到400w數據300G左右的時候,整個數據的插入會變得特別慢(索引重建)甚至會致使集羣之間的通訊斷開,因而咱們採用天天一個index的方法來緩解壓力,logstash 默認是支持天天產生索引的默認名爲 logstash-yyyy.MM.dd 那麼咱們怎麼才能重命名它呢,或者當咱們有多個logstash實例的時候怎麼才能讓他們分別開來。json

 

     其實logstash的es  output中  有幾個參數是控制此選項的:app

     

    index => "dylocation-%{+YYYY.MM.dd}" // 和模板中得template 名稱 匹配  若是匹配ok 則採用此模板
    template_overwrite => true  //  覆蓋當前模板的一個參數 覆蓋 template 和 template_name  elasticsearch

    

   其實呢  index的名字是和logstash中output 中得elasticsearch中得 template 匹配的怎麼個匹配法呢 咱們看看 默認的一個模板spa

   /xxx/logstash/lib/logstash/outputs/elasticsearch  下的  elasticsearch-template.jsoncode

  

{
  "template" : "logstash-*",
  "settings" : {
    "index.refresh_interval" : "5s"
  },
  "mappings" : {
    "_default_" : {
       "_all" : {"enabled" : true},
       "dynamic_templates" : [ {
         "string_fields" : {
           "match" : "*",
           "match_mapping_type" : "string",
           "mapping" : {
             "type" : "string", "index" : "analyzed", "omit_norms" : true,
               "fields" : {
                 "raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 256}
               }
           }
         }
       } ],
       "properties" : {
         "@version": { "type": "string", "index": "not_analyzed" },
         "geoip"  : {
           "type" : "object",
             "dynamic": true,
             "path": "full",
             "properties" : {
               "location" : { "type" : "geo_point" }
             }
         }
       }
    }
  }
}

   也就說orm

相關文章
相關標籤/搜索