1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| input { file { path => [ "/home/ubuntu/php/webman/runtime/logs/ad-*.log" ] #从头开始读,sincedb_path 文件存在时,会从记录的开始读 start_position => "beginning" #不记录读取文件的位置,测试时候用 sincedb_path => "/dev/null" } }
filter { json { source => "message" } mutate { remove_field => ["event",'file','log', "path", "host", "@version"] } #把日志时间作为es的时间 date { match =>["time","yyyy-MM-dd HH:mm:ss"] #把日志的time解析成对应的格式 timezone => "Asia/Shanghai" } }
output { #stdout { # codec => rubydebug #} elasticsearch { hosts => ["localhost:9200"] # Elasticsearch 服务器的地址和端口 index => "your_custom_index" # 自定义索引名称,替换为你想要的索引名 template_name => "your_custom_template" #template_overwrite => true template_pattern => "your_pattern*" # 指定匹配索引名称的模式 } }
|