【ELK7.4】 logstash模版

一、简介
logstash模版可以定义索引创建时的规范,利用模版可以更轻松的管理es中的索引。

二、配置logstash写入es时自动分片
1、修改logstash配置

cd /data/logstash-7.4.0/config
vim logstash.conf
input {
    
    
  beats {
    
    
    port => 5044
  }
}

output {
    
    
  elasticsearch {
    
    
    hosts => "172.16.12.110:9200"              #es 服务地址
    manage_template => true                    #logstash自动管理模板功能
    index => "filebeat-ceshi"                  #索引的名字
    template => "/data/logstash-7.4.0/config/template.json"  #模板的路径
    template_name => "template"                #模板的名字
    template_overwrite => false                ##是否覆盖已存在的模板
  }
}
#覆盖之前上传的模板修改“template_overwrite”为“true”即可。

2、编写模板

vim template.json
{
    
    
     "template": "filebeat-*",        //模板匹配规则,已经索引名匹配
       "settings": {
    
    
           "index.number_of_shards": 2,   //分片数
           "number_of_replicas": 1      //每个分配备份数
       },
    "mappings": {
    
    
      }
}
#写入配置文件时不能要注释

おすすめ

転載: blog.csdn.net/qq_37837432/article/details/108385252