Skip to content

Instantly share code, notes, and snippets.

@roopendra
Created November 25, 2016 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roopendra/886447c6de6e413ad1a00e2a5fc0cdfd to your computer and use it in GitHub Desktop.
Save roopendra/886447c6de6e413ad1a00e2a5fc0cdfd to your computer and use it in GitHub Desktop.
Logstash conf to parse apache log and remove additional geoip and agent fields.
input {
stdin { }
}
filter {
grok {
match => {
"message" => '%{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "%{WORD:verb} %{DATA:request} HTTP/%{NUMBER:httpversion}" %{NUMBER:response:int} (?:-|%{NUMBER:bytes:int}) %{QS:referrer} %{QS:agent}'
}
}
date {
match => [ "timestamp", "dd/MMM/YYYY:HH:mm:ss Z" ]
locale => en
}
geoip {
source => "clientip"
}
useragent {
source => "agent"
target => "useragent"
}
mutate {
remove_field => ["timestamp", "ident", "httpversion","[useragent][os_major]","[useragent][os_minor]","[useragent][major]","[useragent][minor]","[geoip][region_code]","[geoip][region_name]","[geoip][latitude]","[geoip][longitude]","[geoip][dma_code]","[geoip][continent_code]","[geoip][country_code3]"]
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "apache_access_5"
template => "apache_sizing_1.json"
template_name => "elk_workshop"
template_overwrite => true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment