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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| input { beats { port => 5044
} }
filter { grok { match => {"message" => "%{EXIM_DATE:timestamp}\|%{LOGLEVEL:log_level}\|%{INT:pid}\|%{GREEDYDATA}"}
}
if [fields][function]=="nginx" { grok { match => {"source" => "/var/log/nginx/%{GREEDYDATA:path}.log%{GREEDYDATA}"} } }
else if [fields][function]=="ims" { grok { match => {"source" => "/var/log/%{GREEDYDATA:path}/%{GREEDYDATA}"} } }
else { grok { match => {"source" => "/var/log/app/%{GREEDYDATA:path}/%{GREEDYDATA}"} } }
if [fields][function] { mutate { add_field => { "function" => "%{[fields][function]}" } } }
else { mutate { add_field => { "function" => "live" } } }
date { match => ["timestamp" , "yyyy-MM-dd HH:mm:ss Z"] target => "@timestamp" timezone => "Asia/Singapore" }
mutate { gsub => ["path","/","-"] rename => { "old_field" => "new_field" } add_field => {"host_ip" => "%{[fields][host]}"} remove_field => ["tags","@version","offset","beat","fields","exim_year","exim_month","exim_day","exim_time","timestamp"] }
}
output { elasticsearch { hosts => ["localhost:9200"] index => "sg-%{function}-%{path}-%{+xxxx.ww}"
} }
|