Skip to content

Instantly share code, notes, and snippets.

@guixing
Last active December 22, 2015 12:39
Show Gist options
  • Save guixing/6474016 to your computer and use it in GitHub Desktop.
Save guixing/6474016 to your computer and use it in GitHub Desktop.
input {
file {
path => "/var/log/messages"
type => "syslog"
}
file {
path => "/var/log/php_errors.log"
type => "phperror"
}
file {
path => "/var/log/httpd/access_log"
type => "apache_access"
}
file {
path => "/var/log/httpd/error_log"
type => "apache_error"
}
}
filter {
if [type] == "apache_access" {
grok {
match => ["message", "%{COMBINEDAPACHELOG}"]
}
} else if [type]== "syslog" {
grok {
match => ["message", "%{SYSLOGBASE2} %{GREEDYDATA:message}" ]
overwrite => ["message"]
}
} else if [type] == "phperror" {
grok {
patterns_dir => "./p"
match => ["message", "%{PHP_LOG}"]
overwrite => ["message"]
}
}
}
output {
#stdout { codec => rubydebug }
elasticsearch { embedded => true }
if [type] == "apache_access" {
statsd {
host => "localhost"
port => 8125
namespace => "logstash"
increment => "apache.httpcode.%{response}"
}
} else if [type] == "phperror" {
statsd {
host => "localhost"
port => 8125
namespace => "logstash"
increment => "phperror.level.%{level}"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment