Skip to content

Instantly share code, notes, and snippets.

@alhafoudh
Created August 23, 2014 22:11
Show Gist options
  • Save alhafoudh/1b4803347efa36d586da to your computer and use it in GitHub Desktop.
Save alhafoudh/1b4803347efa36d586da to your computer and use it in GitHub Desktop.
Logstash watch docker logs
input {
file {
codec => json
path => '/var/lib/docker/containers/*/*-json.log'
}
}
filter {
ruby {
code => "Thread.current[event['path']] ||= JSON.parse(Pathname(event['path']).dirname.join('config.json').read)"
}
ruby {
code => "event['container_name'] = Thread.current[event['path']].fetch('Name', '<missing>')"
}
ruby {
code => "event['container_image'] = Thread.current[event['path']]['Config'].fetch('Image', '<missing>')"
}
}
output {
stdout {
codec => rubydebug
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment