Skip to content

Instantly share code, notes, and snippets.

@allanbatista
Last active August 15, 2018 14:14
Show Gist options
  • Save allanbatista/b19a27f540ecf2264d6999d71cc8546a to your computer and use it in GitHub Desktop.
Save allanbatista/b19a27f540ecf2264d6999d71cc8546a to your computer and use it in GitHub Desktop.
How Configure Docker to delivery log to logstash
# /etc/docker/daemon.json
{
"log-driver": "gelf",
"log-opts": {
"gelf-address": "udp://127.0.0.1:12201",
"labels": "production_status",
"env": "os,customer"
}
}
# /etc/logstash/conf.d/logstash.conf
input {
gelf {}
}
filter {
ruby {
code => "
require 'json'
parsed = JSON.parse(event.get('message')) rescue {}
event.set('message_parsed', parsed)
"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "index_name-%{+YYYY.MM.dd}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment