Skip to content

Instantly share code, notes, and snippets.

@blkperl
Created September 30, 2014 05:45
Show Gist options
  • Save blkperl/6e78a82f6c09fbb49308 to your computer and use it in GitHub Desktop.
Save blkperl/6e78a82f6c09fbb49308 to your computer and use it in GitHub Desktop.
apache logstash
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