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

       也就说

  • 相关阅读:
    面试题汇总
    Chromium中多线程及并发技术要点(C/C++)
    关于《Swift开发指南》背后的那些事
    HDU 3080 The plan of city rebuild(除点最小生成树)
    2.1.3策略模式(5.9)
    Shell脚本之监视指定进程的执行状态
    敏捷开发中的10大错误认识
    mysql插入中文数据报错:incorrect string value
    JapserReport导出PDF Could not load the following font错误
    冒泡排序
  • 原文地址:https://www.cnblogs.com/huangpeng1990/p/5034452.html
Copyright © 2020-2023  润新知