Skip to content

Instantly share code, notes, and snippets.

@gonzalad
Created July 5, 2016 13:48
Show Gist options
  • Save gonzalad/2e52589db3780755e8af34a38893d75a to your computer and use it in GitHub Desktop.
Save gonzalad/2e52589db3780755e8af34a38893d75a to your computer and use it in GitHub Desktop.
input {
file {
path => "/var/log/apache2/other_vhosts_access.log"
type => "apache"
start_position => beginning
ignore_older => 0
#sincedb_path => "/dev/null"
}
file {
path => "/home/agonzalez/git-projects/platform-services/sandbox/agonzalez-app/data-service/data-service.json.log"
type => "log4j-json"
codec => json
start_position => beginning
ignore_older => 0
#sincedb_path => "/dev/null"
}
}
filter {
if [type] == "apache" {
grok {
match => [ "message", "%{COMBINEDAPACHELOG}" ]
add_field => { "appName" => "websrv" }
remove_field => [ "ident", "auth", "timestamp", "httpversion", "bytes", "referrer", "agent" ]
}
}
else if [type] == "log4j-json" {
mutate {
rename => { "[mdc][httpMethod]" => "verb" }
rename => { "[mdc][appName]" => "appName" }
rename => { "[mdc][X-B3-TraceId]" => "corelationId" }
rename => { "[mdc][appVersion]" => "appVersion" }
rename => { "[mdc][source_host]" => "clientip" }
rename => { "[mdc][request]" => "request" }
remove_field => [ "mdc", "source_host", "file" ]
}
}
}
output {
stdout { codec => json }
elasticsearch {
hosts => ["127.0.0.1:9200"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment