试过各种方法,最终存储到es,发现在grok定义的变量%{}无法在后面获取,最终es索引中只有一个message,没有clientip、ident、auth之类变量,但是网上看到别人的都可以存储input{file{path=>"/var/tomcat8/logs/vg_access_log*.txt"sincedb_path=>"/usr/local/logstash/etc/sincedb_tomcat_log.txt"type=>"tomcat_log"add_field=>{"tomcatip"=>"xxx"}}}filter{if[type]=="tomcat_log"{grok{match=>{"message"=>"%{IPORHOST:clientip}%{USER:ident}%{USER:auth}\[%{HTTPDATE:timestamp}\]\"(?:%{WORD:verb}%{URIPATHPARAM:request}(?:HTTP/%{NUMBER:httpversion})?|-)\"%{NUMBER:response}(?:%{NUMBER:bytes}|-)%{NUMBER:responsetime}\"(?:%{URI:referrer}|-)\"%{QS:agent}"}}kv{source=>"request"field_split=>"&?"value_split=>"="}date{match=>["timestamp","dd/MMM/yyyy:HH:mm:ssZ"]target=>["writetime"]}mutate{convert=>{"response"=>"integer""bytes"=>"integer""responsetime"=>"integer"}}}}output{if[type]=="tomcat_log"{elasticsearch{hosts=>["xxx:9200"]index=>"tomcat-log-%{+YYYY.MM.dd}"}}}
Helenr
相关分类