Created
September 30, 2014 05:45
-
-
Save blkperl/6e78a82f6c09fbb49308 to your computer and use it in GitHub Desktop.
apache logstash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
file { | |
path => [ "/mnt/weblogs/*access.log" ] | |
type => "apache-access" | |
sincedb_path => "/opt/logstash/sincedb-access" | |
} | |
file { | |
path => [ "/mnt/weblogs/*error.log" ] | |
type => "apache-error" | |
sincedb_path => "/opt/logstash/sincedb-error" | |
} | |
} | |
filter { | |
if [type] == "apache-access" { | |
grok { | |
match => | |
{ | |
"message" => "%{COMBINEDAPACHELOG}" | |
singles => true | |
} | |
} | |
if [agent] { | |
useragent { | |
source => "agent" | |
} | |
} | |
if [clientip] | |
{ | |
geoip | |
{ | |
source => "clientip" | |
target => "geoip" | |
add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ] | |
add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}" ] | |
} | |
mutate | |
{ | |
convert => [ "[geoip][coordinates]", "float" ] | |
} | |
} | |
} | |
if [type] == "apache-error" | |
{ | |
grok | |
{ | |
patterns_dir => [ "/etc/logstash/patterns" ] | |
match => | |
[ | |
"message", "%{MODSECAPACHEERROR}", | |
"message", "%{GENERICAPACHEERROR}" | |
] | |
} | |
if [agent] { | |
useragent { | |
source => "agent" | |
} | |
} | |
if [sourcehost] | |
{ | |
geoip | |
{ | |
source => "sourcehost" | |
target => "geoip" | |
add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ] | |
add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}" ] | |
} | |
mutate | |
{ | |
convert => [ "[geoip][coordinates]", "float" ] | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment