Logstash-5.0同步.json文件到ElasticSearch-5.0配置文件

logstash/conf/input-file.conf内容如下:

input {
    file {
        #监听文件的路径。
        path => ["E:/data_json/*.json"]
        #排除不想监听的文件
        #exclude => "1.log"
        
        #添加自定义的字段
        #add_field => {"test"=>"test"}
        #增加标签
        #tags => "tag1"

        #设置新事件的标志
        #delimiter => "\n"

        #设置多长时间扫描目录,发现新文件
        discover_interval => 1
        #设置多长时间检测文件是否修改
        stat_interval => 1

        #监听文件的起始位置,默认是end
        start_position => beginning

        #在logstash-5.0中,json_lines插件貌似不起作用?
        #codec => json_lines {charset => ["UTF-8"]}
        
        #监听文件读取信息记录的位置
        #sincedb_path => "E:/logstash-5.0.0/sincedb_path.txt"
        #设置多长时间会写入读取的位置信息
        #sincedb_write_interval => 15
       
    }
}

filter {
  json {
    #add_field => ... # default: {}
    #add_tag => ... # array (optional), default: []
    #remove_field => ... # array (optional), default: []
    #remove_tag => ... # array (optional), default: []
    source => "name"
    target => "user_name"
  }
}

output {
  elasticsearch {
    #ESIP地址与端口
    hosts => "localhost:9200"
    #ES索引名称(自己定义的)
    index => "m8"
    #自增ID编号
    #document_id => "%{id}"
  }
  stdout {
    #以JSON格式输出
    #codec => json_lines
  }
}

启动logstash命令:

bin/logstash -f ../config/input-file.conf

 

posted @ 2016-11-08 22:29  xuxy03  阅读(2599)  评论(0编辑  收藏  举报