zoukankan      html  css  js  c++  java
  • logstash 输出到elasticsearch 自动建立index

          由于es 单index 所能承受的数据量有限,之前情况是到400w数据300G左右的时候,整个数据的插入会变得特别慢(索引重建)甚至会导致集群之间的通信断开,于是我们采用每天一个index的方法来缓解压力,logstash 默认是支持每天产生索引的默认名为 logstash-yyyy.MM.dd 那么我们怎么才能重命名它呢,或者当我们有多个logstash实例的时候怎么才能让他们分别开来。

         其实logstash的es  output中  有几个参数是控制此选项的:

         

        index => "dylocation-%{+YYYY.MM.dd}" // 和模板中得template 名称 匹配  如果匹配ok 则采用此模板
        template_overwrite => true  //  覆盖当前模板的一个参数 覆盖 template 和 template_name  

        

       其实呢  index的名字是和logstash中output 中得elasticsearch中得 template 匹配的怎么个匹配法呢 我们看看 默认的一个模板

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

      

    {
      "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" }
                 }
             }
           }
        }
      }
    }

       也就说

  • 相关阅读:
    Python——数据类型之list、tuple
    Python——数据类型初步:Numbers
    Python——初识Python
    Python——开篇之词
    PAT——乙级1028
    PAT——甲级1009:Product of Polynomials;乙级1041:考试座位号;乙级1004:成绩排名
    PAT——甲级1065:A+B and C(64bit) 乙级1010一元多项式求导
    PAT——甲级1046S:shortest Distance
    PAT——甲级1042:Shuffling Mashine
    特征值和特征向量
  • 原文地址:https://www.cnblogs.com/huangpeng1990/p/5034452.html
Copyright © 2011-2022 走看看