Skip to content

Instantly share code, notes, and snippets.

@sirhopcount
Forked from silverl/gist:11407510
Created June 11, 2014 09:15
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 sirhopcount/3782dfae2f1335cdbe92 to your computer and use it in GitHub Desktop.
Save sirhopcount/3782dfae2f1335cdbe92 to your computer and use it in GitHub Desktop.
if [type] == "apache-access" or [type] == "apache-error" {
geoip {
source => "clientip"
database => "/opt/logstash/vendor/geoip/GeoLiteCity.dat"
}
if [agent] != "-" {
useragent {
source => "agent"
target => "ua"
add_tag => [ "UA" ]
regexes => "/etc/logstash/regexes.yaml"
}
}
if [type] == "apache-access" {
grok {
match => [ "message", "%{COMBINEDAPACHELOG}" ]
}
}
else if [type] == "apache-error" {
grok {
patterns_dir => [ "/etc/logstash/patterns.d" ]
match => [ "message", "%{APACHE_ERROR_LOG}" ]
}
if !("_grokparsefailure" in [tags]) {
mutate {
remove_field => [ "message" ]
add_field => ["timestamp_submitted", "%{@timestamp}"]
}
date {
# Try to pull the timestamp from the 'timestamp' field (parsed above with
# grok). The apache time format looks like: "18/Aug/2011:05:44:34 -0700"
# Sat Feb 08 06:31:09 2014
match => [ "timestamp", "EEE MMM dd HH:mm:ss yyyy" ]
remove_field => [ "timestamp" ]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment